Last active
March 7, 2022 20:01
-
-
Save nackjicholson/5d7d90a49c36b9a61038e6f4e1b33718 to your computer and use it in GitHub Desktop.
Create and cloudformation stack and wait for it to complete.
This file contains 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
#!/usr/bin/env bash | |
STACK_NAME=$1 | |
STACK_PATH=$2 | |
if [ -z "$1" ] | |
then | |
echo "No STACK_NAME argument supplied" | |
exit 1 | |
fi | |
if [ -z "$2" ] | |
then | |
echo "No STACK_PATH argument supplied" | |
exit 1 | |
fi | |
STACK_DIR="$(dirname ${STACK_PATH})" | |
STACK_TMPL="$(basename ${STACK_PATH})" | |
echo "Creating stack..." | |
STACK_ID=$( \ | |
aws cloudformation create-stack \ | |
--stack-name ${STACK_NAME} \ | |
--template-body file://${STACK_PATH} \ | |
--capabilities CAPABILITY_IAM \ | |
--parameters file://${STACK_DIR}/parameters.json \ | |
--tags file://${STACK_DIR}/tags.json \ | |
| jq -r .StackId \ | |
) | |
echo "Waiting on ${STACK_ID} create completion..." | |
aws cloudformation wait stack-create-complete --stack-name ${STACK_ID} | |
aws cloudformation describe-stacks --stack-name ${STACK_ID} | jq .Stacks[0].Outputs |
This file contains 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
#!/usr/bin/env bash | |
STACK_NAME=$1 | |
STACK_PATH=$2 | |
if [ -z "$1" ] | |
then | |
echo "No STACK_NAME argument supplied" | |
exit 1 | |
fi | |
if [ -z "$2" ] | |
then | |
echo "No STACK_PATH argument supplied" | |
exit 1 | |
fi | |
STACK_DIR="$(dirname ${STACK_PATH})" | |
STACK_TMPL="$(basename ${STACK_PATH})" | |
echo "Updating stack..." | |
STACK_ID=$( \ | |
aws cloudformation update-stack \ | |
--stack-name ${STACK_NAME} \ | |
--template-body file://${STACK_PATH} \ | |
--capabilities CAPABILITY_IAM \ | |
--parameters file://${STACK_DIR}/parameters.json \ | |
--tags file://${STACK_DIR}/tags.json \ | |
| jq -r .StackId \ | |
) | |
echo "Waiting on ${STACK_ID} to update..." | |
aws cloudformation wait stack-update-complete --stack-name ${STACK_ID} | |
aws cloudformation describe-stacks --stack-name ${STACK_ID} | jq .Stacks[0].Outputs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is how I set them up.
Use:
Note you need the
jq
library for this script to run.brew install jq