Skip to content

Instantly share code, notes, and snippets.

@haoyayoi
Last active April 2, 2020 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haoyayoi/548c4bd492c4b1e25eabf681a4bb205a to your computer and use it in GitHub Desktop.
Save haoyayoi/548c4bd492c4b1e25eabf681a4bb205a to your computer and use it in GitHub Desktop.
Get cfn error status.
#!/bin/sh
function usage() {
echo "./check_stack_error [stackname]"
}
function dump_error() {
stacks=$1
for stackname in $stacks
do
echo "======================================="
echo "[$stackname]"
aws cloudformation describe-stack-events --stack-name $stackname | jq -r '.StackEvents[] | select(.ResourceStatus | contains("FAILED")) | "[" + .Timestamp + "] " + .ResourceStatus + " : " + .LogicalResourceId + " : " + .ResourceStatusReason'
done
echo "======================================="
}
if [ $# -eq 1 -a "$1" = "-h" ]; then
usage
exit 0
fi
stacks=$(aws cloudformation describe-stacks | jq -r '.Stacks[].StackName')
if [ $# -gt 0 ]; then
stacks=$@
fi
dump_error "$stacks"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment