Created
April 20, 2023 23:18
-
-
Save siddolo/5d451f65de57e5ebb6be751d647e0ed1 to your computer and use it in GitHub Desktop.
Build & deploy AWS lambda Makefile
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
FUNCTION_NAME = lambda-name | |
FUNCTION_ENVIRONMENT = python3.9 | |
AWS_PROFILE = awscli-credential-profile | |
PWD = $(abspath $(CURDIR)) | |
RELEASE_DST_PATH = $(addprefix $(PWD), /release) | |
ZIP_EXTRA_IGNORE_PATH_ARGS = -x '.env' \ | |
-x '.gitignore' -x '*/.gitignore' \ | |
-x '.git/**' -x '.git/' \ | |
-x 'release/**' -x 'release/' \ | |
-x '.venv/**' -x '.venv/' \ | |
-x '*/__pycache__/**' -x '*/__pycache__/' | |
all: package | |
clean: | |
docker run -v $(PWD):/var/task public.ecr.aws/sam/build-$(FUNCTION_ENVIRONMENT) rm -rf ./release/tmp | |
package: | |
docker run -v $(PWD):/var/task public.ecr.aws/sam/build-$(FUNCTION_ENVIRONMENT) pip install --target ./release/tmp -r requirements.txt | |
rm -f $(RELEASE_DST_PATH)/$(FUNCTION_NAME).zip | |
cd ./release/tmp ; zip -r $(RELEASE_DST_PATH)/$(FUNCTION_NAME).zip . | |
zip -r $(RELEASE_DST_PATH)/$(FUNCTION_NAME).zip . $(ZIP_EXTRA_IGNORE_PATH_ARGS) | |
deploy: | |
aws --profile $(AWS_PROFILE) lambda update-function-code --function-name $(FUNCTION_NAME) --zip-file fileb://$(RELEASE_DST_PATH)/$(FUNCTION_NAME).zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment