Skip to content

Instantly share code, notes, and snippets.

@ugurerkan
Created November 1, 2021 15:27
Show Gist options
  • Save ugurerkan/ea18723db7f94d6c600ecf1dc7142459 to your computer and use it in GitHub Desktop.
Save ugurerkan/ea18723db7f94d6c600ecf1dc7142459 to your computer and use it in GitHub Desktop.
AWS Lambda Deploy Script
#!/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