Created
November 1, 2021 15:27
-
-
Save ugurerkan/ea18723db7f94d6c600ecf1dc7142459 to your computer and use it in GitHub Desktop.
AWS Lambda Deploy Script
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
#!/bin/bash | |
# AWS Lambda Deploy Script | |
# | |
# Shell helper for deploy lambda functions | |
# Make sure aws cli configured and installed before | |
FUNCTION_NAME="my-lambda-script" | |
function package() { | |
zip -r function.zip node_modules index.js \ | |
--exclude '*.md' \ | |
--exclude '*.min.js' \ | |
--exclude '*.map' \ | |
--exclude '*.ts' \ | |
--verbose | |
} | |
function deploy () { | |
read -p "Enter environment (LOCAL): " ENV | |
ENV=${ENV:-LOCAL} | |
# create function package | |
package; | |
# upload file | |
aws lambda update-function-code --function-name "$FUNCTION_NAME-$ENV" --zip-file fileb://function.zip | |
# clean artifact | |
rm function.zip | |
} | |
echo "Chose operation mode" | |
echo " - type p for package" | |
echo " - type d for deploy" | |
read -p "Operation: " OPERATION | |
OPERATION=${OPERATION:-p} | |
case $OPERATION in | |
p) | |
package | |
;; | |
d) | |
deploy | |
;; | |
*) | |
echo "Unknown operation: $OPERATION" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment