From 2f40915276188d5611effa3aa8c71606cbc83bae Mon Sep 17 00:00:00 2001 From: Joey Freeland Date: Mon, 30 Mar 2026 09:21:07 -0400 Subject: [PATCH] feat: cleanup ebs volumes from testinfra ami's --- .github/workflows/testinfra-ami-build.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/testinfra-ami-build.yml b/.github/workflows/testinfra-ami-build.yml index c071737e99..f2d083bbcc 100644 --- a/.github/workflows/testinfra-ami-build.yml +++ b/.github/workflows/testinfra-ami-build.yml @@ -146,8 +146,17 @@ jobs: if [ -n "$STAGE2_AMI_IDS" ]; then for ami_id in $STAGE2_AMI_IDS; do + SNAPSHOT_IDS=$(aws ec2 describe-images \ + --region ap-southeast-1 \ + --image-ids "$ami_id" \ + --query 'Images[*].BlockDeviceMappings[*].Ebs.SnapshotId' \ + --output text) echo "Deregistering stage 2 AMI: $ami_id" aws ec2 deregister-image --region ap-southeast-1 --image-id "$ami_id" || true + for snap_id in $SNAPSHOT_IDS; do + echo "Deleting snapshot: $snap_id" + aws ec2 delete-snapshot --region ap-southeast-1 --snapshot-id "$snap_id" || true + done done else echo "No stage 2 AMI to clean up"