Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test stack remover script #1226

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"