Skip to content

Commit ee348e4

Browse files
authored
Merge pull request #1226 from buildkite/cleanup-script
Add test stack remover script
2 parents 577fbb6 + 898ab37 commit ee348e4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

utils/test-stack-remover.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
# The CI for this repo can sometimes leave some stacks lying around - every couple of months we need to clean them up.
4+
# This script will delete any stacks that are in DELETE_FAILED state, that contain the word _test_ in their name, and
5+
# that are not autoscaling stacks (these are child stacks that will be deleted when their parent is deleted)
6+
7+
set -euo pipefail
8+
9+
aws cloudformation list-stacks \
10+
| jq -r ".StackSummaries[] | {StackName, StackStatus} | select(.StackStatus == \"DELETE_FAILED\").StackName" \
11+
| grep test \
12+
| grep -vi autoscaling \
13+
| sort | uniq \
14+
| xargs -t -I {} aws cloudformation delete-stack \
15+
--stack-name {} \
16+
--role-arn "$ROLE_ARN"

0 commit comments

Comments
 (0)