Skip to main content

AWSDeployer

Collection of some scripts to automate AWS Lambda deployments. They are useful for quick development and deployment of AWS Lambda functions and layers, as well as a REST API Gateway integration.

Just set your working directory, your awsdeployer configs and you should be good to focus on actual development.

Currently only supporting Python lambda functions.


Lambda Deployer

Easily deploy Lambda functions and their layers.

Usage

These scripts assume a working directory like that of sample_lambda:

  • awsdeployer.ini file with your secrets (see sample file)
  • awsdeployer_lambda.json with your layer and function configurations
  • function_name.py files, one for each of your Lambda functions

The executable is lambda, which accepts the following commands:

  • $ lambda layer <layer-name>: deploy layer "layer-name" into AWS (requires docker to build)
  • $ lambda config [<function-name>]: update all function configs in AWS (specify a function name to only update that function's configs); non-existing functions are created (default Lambda IAM permissions)
  • $ lambda <function-name>: if no option above is matched, the specified function has its code and configs updated (probably the most common case); non-existing functions are created (default Lambda IAM permissions)

Tip: all parameters can be replaced by a shorthand, which you can specify in your awsdeployer_lambda.json.

Configs

  • main_file: specify the main function file (if not present, function_name.py is assumed)
  • additional_files: additional files to include with the main function file in the deployment

Environment packages

If you need to add the same set of variables to multiple functions (eg. database configurations) you can define a global pack of environment variables that you can then reference in each function that needs it. Example in samples/lambda/awsdeployer_lambda.json

Special layer building

If you need to build a specific package for your layer (eg. psycopg2) you can use pre and post build hooks for the layer build, and add docker arguments to the command.

To build psycopg2 compile it separately, then use these configs:

"layer_configs": {
    "psycopg2layer": {
        "requirements_file": "requirements.txt",
        "requirements_ignore": ["psycopg2"],
        "build_args": "-v ~/psycopg2-build:/bar",
        "pre_build_command": "echo 'Something before pip'",
        "post_build_command": "cp -r /bar /foo/python/psycopg2",
        "common": true
    }
}

API Gateway Deployer

Easily deploy API gateway, handling input parameters and error codes, so you can focus on the code.

Usage

These scripts assume a working directory like that of sample_apigateway:

  • awsdeployer.ini file with your secrets (see sample file)
  • awsdeployer_api.json with your API definition in JSON (NOT nested!)
  • function_xxxx.py files, one for each of your Lambda functions associated with the endpoints

The apigateway executable accepts two commands:

  • $ apigateway all: deploy the full API (destroys already existing ones)
  • $ apigateway <method> <path>: deploy a single method (also destroys already existing ones)

The script also helps automating HTTP error codes, which you can find in status_codes.md. They are automatically deployed into API Gateway and caught by it, as long as you import the awsdeployer package, as seen in sample_apigateway/get.py. If you're not using Python, your errors should follow the following JSON syntax to be caught effectively:

{
    'gatewayResponse': True,
    'status': 'error',
    'type': _status_code_from_md_file,
    'userMessage': your_user_message_which_can_be_empty
}

Metadata

Release files for awsdeployer 1.15.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for awsdeployer 1.15.1
File Size Uploaded
awsdeployer-1.15.1.tar.gz 17.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for awsdeployer 1.15.1
File Interpreter ABI Platform
awsdeployer-1.15.1-py3-none-any.whl Python 3 none any Details

Total release size: 49.2 kB

Release files / awsdeployer-1.15.1.tar.gz

Download URL awsdeployer-1.15.1.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fecdab8d528e04e1e4e7f488c33a82615ac48d6d20f3bbf325462f8e8db14ad3
BLAKE2b-256 checksum
How to use checksums
492556800cd197602816dabb7f8621218eb11074e0bc95a19cad3d582991e6b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.6

Release files / awsdeployer-1.15.1-py3-none-any.whl

Download URL awsdeployer-1.15.1-py3-none-any.whl
Size 32.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e85c4887c4a3d87c491385642d9601fe33a8bb290b238a5599d6cafcc1a57e3a
BLAKE2b-256 checksum
How to use checksums
c12e3ed9c933c2b02c554dff4c3c7998038c6d5f1cec2195b08a906813f0bfbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.6

Release history Release notifications | RSS feed

This release

1.15.1 This release

2 release files

1.15.0

2 release files

1.14.0

2 release files

1.13.0

2 release files

1.11.0

2 release files

1.10.0

2 release files

1.9.2

2 release files

1.9.1

2 release files

1.9

2 release files

1.8.2

1 release file

1.8.1

1 release file

1.8.0

1 release file

1.7.1

1 release file

1.7.0

1 release file

1.6.0

1 release file

1.5.0

1 release file

1.4.2

1 release file

1.4.1

1 release file

1.4.0

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page