Skip to content

Commit

Permalink
Add test stack remover script
Browse files Browse the repository at this point in the history
  • Loading branch information
moskyb committed Oct 11, 2023
1 parent ea0d8bf commit 898ab37
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions utils/test-stack-remover.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# The CI for this repo can sometimes leave some stacks lying around - every couple of months we need to clean them up.
# This script will delete any stacks that are in DELETE_FAILED state, that contain the word _test_ in their name, and
# that are not autoscaling stacks (these are child stacks that will be deleted when their parent is deleted)

set -euo pipefail

aws cloudformation list-stacks \
| jq -r ".StackSummaries[] | {StackName, StackStatus} | select(.StackStatus == \"DELETE_FAILED\").StackName" \
| grep test \
| grep -vi autoscaling \
| sort | uniq \
| xargs -t -I {} aws cloudformation delete-stack \
--stack-name {} \
--role-arn "$ROLE_ARN"

0 comments on commit 898ab37

Please sign in to comment.