References repo -> docker-lambda by lambci, python-amazonlinux by RealSalmon.
This Python repo will help you to develop, test (on virtual AWS Lambda via docker) and build/deploy to AWS Lambda easily.
- Working on Max OSX only.
- Minimum 4GB disk space required (reserved for docker images).
- Python version 3.6 (manage python version very very easy by using pyenv).
- Python Virtualenv either use virtualenv or pyenv-virtualenv.
- Docker Compose version >= 1.9.
- AWS IAM with Lambda & S3 Roles apply (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are required).
- Indeed!!, some Python knowledge.
- Checks and satisfied prerequisites.
- Activated virtualenv for this repo (on local) follow these step -> virtualenv or pyenv-virtualenv (depend on virtualenv management you use).
- Let's Rock!!
See /lambda/example directory for an example usage.
You can create new directory beneath /lambda for any lambda module. All dir will have their own python dependencies (list by requirements.txt and can't use a specific version for now).
Lambda module and its handler function could be named in your favour, the script will ask for them later.
Try it by simple run...
python run.py
You will see 3 options available if pass python and virtualenv prerequisite checked.
- Install all python dependencies to your virtualenv for development process (better for working with IDE Autocomplete) which defined in each lambda module directory (by using requirements.txt)
- Run test function on AWS Lambda environment (operate by docker). When you run this option, event.json will be inject for testing the handler.
- Build and deploy to AWS Lambda. S3 Bucket is needed, the script will upload the zip file to S3 (named s3:///lambda/-<timestamp>.zip) and lambda will pull from it to replace function. Also please make sure all of your python dependencies should not produce a very large zip file because of the limit of Lambda for Compress package is just 50MB. See details AWS Lambda Limit
After choose the option... follow the step to proceed and that's it.