Last active
January 14, 2020 13:10
-
-
Save leonaaraujo/7dd3c6857bb862cddc8278aa4f9817cb to your computer and use it in GitHub Desktop.
Fire - AWS SAM shell script template
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/sh | |
# VARIABLES | |
CMD=$1 | |
PROJECT="<PROJECT-NAME-HERE>" | |
S3_DEPLOY_BUCKET="<S3-BUCKET-NAME-HERE>" | |
PACKAGE_FILE_NAME="packaged.yaml" | |
EVENTS_FOLDER="events/" | |
ENVIRONMENT_FILE="env.json" | |
ANY_CLOUD_FORMATION_PARAMETER="<ANY-CLOUD-FORMATION-PARAMETER-VALUE>" | |
# GLOBAL FUNCTIONS | |
build() { | |
sam build | |
} | |
start() { | |
build | |
sam local start-api \ | |
--env-vars $EVENTS_FOLDER$ENVIRONMENT_FILE \ | |
--parameter-overrides AnyParameter=$ANY_CLOUD_FORMATION_PARAMETER | |
} | |
debug() { | |
FUNC=$1 | |
EVENT=$2 | |
build | |
sam local invoke --debug \ | |
--event $EVENTS_FOLDER$EVENT.json \ | |
--env-vars $EVENTS_FOLDER$ENVIRONMENT_FILE \ | |
$FUNC \ | |
--parameter-overrides AnyParameter=$ANY_CLOUD_FORMATION_PARAMETER | |
} | |
package() { | |
build | |
sam package \ | |
--s3-bucket $S3_DEPLOY_BUCKET \ | |
--s3-prefix $PROJECT \ | |
--output-template-file $PACKAGE_FILE_NAME | |
} | |
publish() { | |
REGION=$1 | |
package | |
sam publish -t $PACKAGE_FILE_NAME --region $REGION | |
} | |
deps() { | |
dotnet restore # Replace to the current project package manager. | |
} | |
# LOCAL FUNCTIONS | |
# Add here the application exclusive functions. | |
# SWITCH CASE COMMAND | |
case $CMD in | |
# GLOBAL CASES | |
"start") | |
start | |
;; | |
"debug") | |
FUNC=$2 | |
EVENT=$3 | |
debug $FUNC $EVENT | |
;; | |
"build") | |
build | |
;; | |
"package") | |
package | |
;; | |
"deps") | |
deps | |
;; | |
"restore") | |
deps | |
;; | |
"install") | |
deps | |
;; | |
"publish") | |
REGION=$2 | |
publish $REGION | |
;; | |
# LOCAL CASES | |
# Add here the application exclusive command aliases. | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment