Skip to content

Instantly share code, notes, and snippets.

@istepanov
Created November 11, 2017 00:44
Show Gist options
  • Save istepanov/48285351fa206a0aba92615fb9d632c6 to your computer and use it in GitHub Desktop.
Save istepanov/48285351fa206a0aba92615fb9d632c6 to your computer and use it in GitHub Desktop.
Makefile for deploying Python 3 AWS Lambda
PROJECT = myProject
FUNCTION = $(PROJECT)
REGION = us-west-1
ENVCHAIN = my-aws-env
all: build
.PHONY: clean build deploy
clean:
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 \
--publish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment