Created
October 25, 2021 12:22
-
-
Save eamonnfaherty/5eec7ff831adbd0eaa8e922433979fec to your computer and use it in GitHub Desktop.
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 | |
set -e | |
echo "Starting to prune change sets" | |
ALL_STACKS=$(aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETE UPDATE_COMPLETE UPDATE_ROLLBACK_COMPLETE --query 'StackSummaries[].StackName' --output text) | |
for STACK_NAME in $ALL_STACKS | |
do | |
echo "Starting $STACK_NAME" | |
CHANGE_SET_NAMES=$(aws cloudformation list-change-sets --stack-name $STACK_NAME --query 'Summaries[?Status==`FAILED`].ChangeSetName' --output text) | |
for CHANGE_SET_NAME in $CHANGE_SET_NAMES | |
do | |
aws cloudformation delete-change-set --change-set-name $CHANGE_SET_NAME --stack-name $STACK_NAME | |
echo "Deleted $CHANGE_SET_NAME for $STACK_NAME" | |
done | |
echo "Finished $STACK_NAME" | |
done | |
echo "Finished pruning change sets" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will delete all failed change sets for all stacks for the account/region it is run in.