Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Makefile for deploying Python 3 AWS Lambda
PROJECT = myProject
REGION = us-west-1
ENVCHAIN = my-aws-env
all: build
.PHONY: clean build deploy
rm -rf build
build: clean
mkdir -p build/site-packages
zip -r build/$(FUNCTION).zip . -x "*.DS_Store*" "*.git*" "build*" "Makefile" "requirements.txt"
python3 -m venv build/$(FUNCTION)
. build/$(FUNCTION)/bin/activate; \
pip3 install -r requirements.txt; \
cp -r $$VIRTUAL_ENV/lib/python3.6/site-packages/ build/site-packages
cd build/site-packages; zip -g -r ../$(FUNCTION).zip . -x "*__pycache__*"
deploy: build
envchain $(ENVCHAIN) aws lambda update-function-code \
--region=$(REGION) \
--function-name $(FUNCTION) \
--zip-file fileb://build/$(FUNCTION).zip \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment