Created
November 11, 2017 00:44
-
-
Save istepanov/48285351fa206a0aba92615fb9d632c6 to your computer and use it in GitHub Desktop.
Makefile for deploying Python 3 AWS Lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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