Skip to content

fix(toolkit-lib): fail gc on ECR tagging permission errors - #1828

Open
lemon0333 wants to merge 1 commit into
aws:mainfrom
lemon0333:fix/gc-fail-on-ecr-tagging-permission-error
Open

fix(toolkit-lib): fail gc on ECR tagging permission errors#1828
lemon0333 wants to merge 1 commit into
aws:mainfrom
lemon0333:fix/gc-fail-on-ecr-tagging-permission-error

Conversation

@lemon0333

Copy link
Copy Markdown
Contributor

Fixes #347

parallelTagEcr in toolkit-lib's garbage-collector.ts caught every error from ecr:PutImage. The intent was to ignore the benign imageTag-collision false negative (the isolated asset simply gets tagged on the next run), but it also swallowed AccessDeniedException. As a result, when the role is missing the ecr:PutImage permission, cdk gc silently no-ops — no images are tagged or deleted, yet the command reports success.

This change rethrows on access-denied errors (using the existing isAccessDeniedError helper, which already handles the AccessDenied / AccessDeniedException phrasing differences across services), so cdk gc fails as expected on a permission problem. The benign collision case is still ignored.

Verified with a new unit test in garbage-collection.test.ts (ecr:PutImage rejects with AccessDeniedExceptiongarbageCollect() rejects); the full garbage-collection suite passes (29/29).

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

parallelTagEcr caught every error from ecr:PutImage, intending to ignore the
benign imageTag-collision false negative that self-heals on the next run. It
also swallowed AccessDeniedException, so a role missing the ecr:PutImage
permission made cdk gc silently no-op and never report a failure.

Rethrow on access-denied errors (via the existing isAccessDeniedError helper)
so the command fails as expected, while still ignoring the collision false
negative.

Fixes aws#347
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(garbage-collection): gc does not fail on missing permissions

1 participant