Repository navigation
fix(ci): look up only the owned ECR repo in the destroy cleanup - #484
Merged
Merged
Conversation
force-delete-owned-ecr-repo.sh listed every repository in the account and filtered for the owned one. A list-all DescribeRepositories is authorized against repository/*, and the deploy role's ECR grant covers only repository/cudly-*, so every real destroy failed with AccessDenied before the filter ran. Ask for the owned repository by name instead. RepositoryNotFoundException means it is already gone and exits 0; any other error fails with the AWS CLI's exit code. The response still passes through select-owned-name.sh, so only the owned repository can be deleted. The new behaviour tests stub aws to deny the list-all form, as the role does. Closes #483
Contributor
|
Warning Review limit reached
This review includes 2 billable files and costs up to $0.50.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 8 minutes for your next included review. View limit detailsLimit details: You’ve used the included review currently available. Your 76 included PR review attempts over the past 7 days set your current allowance at 1 review per hour. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (2)
Comment |
This was referenced Oct 5, 2026
Closed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/force-delete-owned-ecr-repo.shnow looks up only the owned ECR repository (describe-repositories --repository-names "$OWNED_REPO") instead of listing the whole account.Why
A DescribeRepositories call without
--repository-namesis authorized againstrepository/*. The deploy role's ECR grant (terraform/environments/aws/ci-cd-permissions/policy_compute.tf,ECRRepositoryScoped) covers onlyarn:aws:ecr:*:*:repository/cudly-*, sodestroy-fargate-dev.ymlfailed with AccessDeniedException on run 37244760348 before the filter ran.Change
RepositoryNotFoundExceptionmeans it is already gone: the script prints a message and exits 0. Any other error prints the AWS message and exits with the AWS CLI's exit code. Nothing uses|| true.select-owned-name.sh, so the exact-name check is unchanged and the existing wiring and sweep assertions still apply.select-owned-name.shitself is not modified; the RDS and Cloud SQL scripts also call it.scripts/test-ecr-delete-selection.shstubterraformandaws. Theawsstub denies the list-all form the same way the role does, and covers these cases: repo found (exactly the owned repo is deleted), a different name returned (nothing deleted), RepositoryNotFoundException (exit 0), another error (non-zero, AWS message on stderr), and a failed delete (non-zero).Tests
Pre-fix (new tests against the parent script):
passed: 50, failed: 6, exit 1:Post-fix:
bash scripts/test-ecr-delete-selection.sh->passed: 56, failed: 0.bash scripts/test-rds-deletion-protection-scope.sh->passed: 53, failed: 0.Verification
shellcheck -x scripts/force-delete-owned-ecr-repo.sh: clean. The test file still has its one existing SC2016 info and no new findings.disable-owned-rds-deletion-protection.shalso lists all instances (rds describe-db-instances), butrds:DescribeDBInstancesis granted on*inpolicy_data.tf(RDSDescribeAccountWide), so that call is not denied. Left unchanged.delete-owned-cloud-sql-instance.shis GCP. Its permissions come from project-level IAM, not AWS ARN scoping. Left unchanged.destroy-fargate-dev.ymlandcleanup-staging.ymlmake no other AWS list calls.🤖 Generated with claude-flow