Skip to content

Instantly share code, notes, and snippets.

@martinabrahams
Created December 20, 2021 05:54
Show Gist options
  • Save martinabrahams/0d072d7e273f7e6ec9b37d53e25cf708 to your computer and use it in GitHub Desktop.
Save martinabrahams/0d072d7e273f7e6ec9b37d53e25cf708 to your computer and use it in GitHub Desktop.
This script can be used to hold up a deploy pipeline after a CloudFormation deploy has taken place. This will handle both UPDATE and CREATE events, currently the AWS CLI doesn't support this.
#!/bin/bash
STACK_NAME=my-stack-name
UPDATING=1
while [ "$UPDATING" -ne 0 ]
do
stack_status=$(aws cloudformation describe-stacks --stack-name ${STACK_NAME} | jq -r --arg STACK "$STACK_NAME" '[.Stacks[]|select(.StackName==$STACK)][0].StackStatus')
if [[ "$stack_status" == "PROCESSING_UPDATE" || "$stack_status" == "PROCESSING_CREATE" ]]; then
echo Still processing, stack status ${stack_status}
sleep 10
elif [[ "$stack_status" == "UPDATE_COMPLETE" || "$stack_status" == "CREATE_COMPLETE" ]]; then
echo Processing completed status ${stack_status}
exit 0
else
echo Processing returned failure status ${stack_status}
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment