This repo contains a test deployement of a aws lambda function using:
- terraform (Infrastructure as Code)
- poetry (Package manager)
- pyenv (Python Installation Management)
- virtualenvWrapper (VirtualEnv wrapper to manage python virtual env when developping)
- poetry (projects specification and package dependency management)
- pip (local package manager)
Add pip packages to poetry
pip freeze > requirements.txt
poetry add $(cat requirements.txt)
virtualenvwrapper pip may include package that are not necessary for your project
Deploy your lambda function to AWS
To simplify (using Makefile): run make redeploy-lambda
Package the lambda function
rm -rf package
mkdir package
cp -R $$(poetry env info -p)/lib/python3.9/site-packages* package/
cp -R ./src/ ./packageProvision with Terraform
❗ Don't forget to define your AWS env. variables from the CLI or bysource a .sh file. Example:
source ./set-env.shwith a file that looks like
export AWS_ACCESS_KEY_ID="<AWS_ACCESS_KEY_ID>"
export AWS_SECRET_ACCESS_KEY="<AWS_ACCESS_KEY>"To deploy the terraform config
cd ./tf/
source ./set-env.sh;
terraform planValidate the deployement and run (do this after packaging your lambda function with poetry)
terraform apply