Clone this repo as a starting point for Lambda development.
A set of conventions for local AWS Lambda software development.
. ├── Makefile # Definition of `make` targets. ├── builds # Builds directory. │ ├── deploy-2016-08-15_16-50.zip │ └── deploy-2016-08-15_16-54.zip ├── cloudformation # CloudFormation template and parameters. │ └── parameters.json │ └── template.yaml ├── index.py # Entry point for the Lambda function. ├── my_lambda_package # Python package `my_lambda_package`. │ ├── __init__.py │ ├── localcontext.py │ ├── utility.py ├── requirements # External dependencies. │ ├── common.txt │ ├── dev.txt │ └── lambda.txt └── tests # Unit tests for the package. ├── __init__.py └── my_lambda_package ├── __init__.py ├── test_localcontext.py └── test_utility.py
Creates a CloudFormation stack with the Lambda function, an execution role, and an optional CloudWatch event to run on a recurring basis.
make create-stack
Sets up your local environment for local Python development.
Assume the role created by CloudFormation by creating a new entry in ~/.aws/config:
# ~/.aws/config [profile regular] output = json region = us-west-2 [profile development] output = json region = us-west-2 source_profile = regular role_arn = arn:aws:iam::111111111111:role/LambdaFunctionExecutionRo-34K8PIBFMONR
Set development as the current profile via export AWS_PROFILE=development.
Installs the development requirements from requirements/dev.txt.
In a new virtualenv (pyenv-virtualenv is great), install the local dependencies:
cd local-lambda-toolkit
make initRuns all the unit tests in the tests/ directory.
make testRuns the Python code on your local machine.
make invoke
Creates a deployable Lambda zip file, and places into builds.
make build
Sends the build to a Lambda ARN.
ARN=arn:aws:lambda:us-west-2:111111111111:function:my-function-name make deploy