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 Sep 27, 2023
1 parent 7b3b8a9 commit 6790292
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions utils/test-stack-remover.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/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)

# no -u, as we rely on the $ROLE_ARN variable being passed in
set -eo pipefail

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

0 comments on commit 6790292

Please sign in to comment.