Last active
May 22, 2025 12:38
-
-
Save ldipotetjob/e9e31ff11dd5bea791b50014ba1cb77d to your computer and use it in GitHub Desktop.
Update and Deploy a lambda function to 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
| ROLE_ARN=$(ROLE) | |
| ZIP_FILE=deployment-package.zip | |
| REGION=eu-west-1 | |
| # run under this project structure: https://github.com/ldipotetjob/AWS/blob/main/serverless/lambda/project/structure.md | |
| # keep in mind your security tokens export in your terminal: | |
| # export AWS_ACCESS_KEY_ID=${token_access_key} | |
| # export AWS_SECRET_ACCESS_KEY=${token_secret_key} | |
| # @see: https://makefiletutorial.com/ | |
| # example of use: make all HANDLER=my_lambda_function ROLE=execution_role_of_the_lambda_function | |
| FUNCTION_NAME=$(HANDLER) | |
| all: help build deploy clean | |
| help: | |
| echo "deploying " $(HANDLER) | |
| build: | |
| mkdir -p deployment-package | |
| cp -r src/$(HANDLER)/. src/standard_utils.py deployment-package/ | |
| if [ -f requirements.txt ]; then pip install -r requirements.txt --target deployment-package/; fi | |
| cd deployment-package && zip -r9 ../$(ZIP_FILE) . | |
| deploy: | |
| echo "Deploying lambda function:" $(HANDLER) | |
| aws lambda update-function-code --function-name $(FUNCTION_NAME) --zip-file fileb://$(ZIP_FILE) --region $(REGION) | |
| clean: | |
| rm -rf deployment-package $(ZIP_FILE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment