AWS Test Resource Cleanup #263
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: AWS Test Resource Cleanup | |
| on: | |
| workflow_run: | |
| workflows: ["CI"] | |
| types: [completed] | |
| schedule: | |
| # Safety net: run every 6 hours to catch any orphaned resources | |
| - cron: '0 */6 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| cleanup: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| AWS_REGION: eu-west-1 | |
| AWS_DEFAULT_OUTPUT: json | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Wait for tag propagation | |
| # The AWS Resource Groups Tagging API is eventually consistent. | |
| # Resources created shortly before CI completes may not yet be discoverable by tag. | |
| # 15 seconds provides sufficient margin based on observed propagation times. | |
| run: sleep 15 | |
| - name: Diagnose - count existing resources | |
| run: | | |
| echo "=== SNS Topics ===" | |
| TOPIC_COUNT=$(aws sns list-topics --query 'Topics | length(@)' --output text) | |
| echo "Total topics: $TOPIC_COUNT" | |
| echo "" | |
| echo "=== FIFO Topics ===" | |
| aws sns list-topics --query 'Topics[?ends_with(TopicArn, `.fifo`)].TopicArn' --output text | tr '\t' '\n' | head -50 | |
| FIFO_COUNT=$(aws sns list-topics --query 'Topics[?ends_with(TopicArn, `.fifo`)] | length(@)' --output text) | |
| echo "Total FIFO topics: $FIFO_COUNT" | |
| echo "" | |
| echo "=== SQS Queues ===" | |
| QUEUE_COUNT=$(aws sqs list-queues --query 'QueueUrls | length(@)' --output text 2>/dev/null || echo "0") | |
| echo "Total queues: $QUEUE_COUNT" | |
| echo "" | |
| echo "=== Sample topic names (first 20) ===" | |
| aws sns list-topics --query 'Topics[*].TopicArn' --output text | tr '\t' '\n' | sed 's/.*://' | head -20 | |
| - name: Cleanup orphaned test resources | |
| run: | | |
| chmod +x ./clean_failed_tests_aws_assets.sh | |
| ./clean_failed_tests_aws_assets.sh |