-
-
Save izidorome/523e45cff3407138ebce5421c4c64f9f to your computer and use it in GitHub Desktop.
Makefile for deploying Python 3 AWS Lambda
This file contains hidden or 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