Last active
April 2, 2020 05:58
-
-
Save haoyayoi/548c4bd492c4b1e25eabf681a4bb205a to your computer and use it in GitHub Desktop.
Get cfn error status.
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
#!/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