Example code for packaging a python Lambda function. Demonstrates the exclusion of unwanted code from the package e.g. wheel, setuptools, pip.
-
Create a virtualenv, preferably matching the python version used on AWS:
virtualenv -p python3.6 env -
Install the requirements:
pip install -r requirements.txt -
Optionally use terraform to create the function, IAM role and policy, supporting S3 bucket and object. Defaults to the
stagingAWS profile in your credentials file. Runterraform init,terraform planandterraform apply. -
Run the build and deploy scripts. It uploads quicker and the code can be previewed in the AWS dashboard.
-
Run the function and see a funny.