template-only-bin: Include additional resources in cleanup-test-resources#991
template-only-bin: Include additional resources in cleanup-test-resources#991
cleanup-test-resources#991Conversation
…leanup-test-resources` We just want the status code.
There are other resources types that could block the VPC cleanup, but these are the ones we've seen be left around so far.
eb82720 to
f113af9
Compare
sean-navapbc
left a comment
There was a problem hiding this comment.
Nice improvements to the cleanup script! The refactoring to use the already-fetched resources list instead of re-querying each
resource type is a good simplification. The new helper scripts (delete-iam-role, empty-s3-bucket, list-iam-roles-with-tag)
are well-structured.
Bug Found
Line 358 in cleanup-test-resources: There's a typo in the AWS CLI flag:
role_project_tag=$(aws iam list-role-tags \
--role_name "${role_name}" \Should be --role-name (hyphen) not --role_name (underscore). This will cause the IAM role tag lookup to fail.
Minor Suggestions
-
SNS grep pattern (line 336): The pattern
'arn:aws:sns:.*'could match unintended resources. Consider being more specific
with'arn:aws:sns:.*:.*:'to ensure it only matches topic ARNs. -
VPC dependency order: The script deletes subnets and internet gateways before VPCs, which is correct. However, there may
be other dependencies (NAT gateways, route tables with explicit associations) that could still block VPC deletion. The current
|| echo "Failed..."handling is fine for now, but worth noting for future iterations.
Verdict
Please fix the --role_name → --role-name bug, then this is good to merge
f113af9 to
d334b90
Compare
Good catch! Done.
Topics are the only SNS ARNs AFAIK, which I suppose could change in the future, but if it does this would need updated anyway. So I think it's fine as is. |
|
Manually merged as individual commits: 8e32d98...eb06b65 |
Ticket
Related to #706
Changes
There were a number of resource types not covered by the script that were still left around after initial cleanup, so extend removal coverage to those. Not complete or perfect (e.g., there are a other networking resources that could prevent an VPC from being able to be removed), but covers what we've seen so far.
Context for reviewers
Will probably not squash when merging, but also didn't want to make 12 PRs. So best reviewed commit by commit for logical chunks.
Testing
--dry-runresource list before: clean-pre-results.txt--dry-runresource list after: clean-post-final-tweaks.txtInfra tests are now passing: https://github.com/navapbc/template-infra/actions/runs/21011517717/job/60517259169