fix(cli): bootstrap FilePublishingRoleDefaultPolicy KMS permission when FileAssetsBucketKmsKeyId is an ARN - #1880
Open
lemon0333 wants to merge 1 commit into
Open
Conversation
…AssetsBucketKmsKeyId is an ARN
The bootstrap template always constructed the KMS resource ARN for the
FilePublishingRoleDefaultPolicy as
'arn:${Partition}:kms:${Region}:${AccountId}:key/${FileAssetsBucketKmsKeyId}'.
The FileAssetsBucketKmsKeyId parameter description explicitly permits either a
key ID or a full key ARN, so when a (cross-account) key ARN is supplied this
produced a malformed 'arn:...:key/arn:aws:kms:...' value and an invalid IAM
policy statement.
Add a HasCustomKmsKeyArn condition that detects the ARN form (first
':'-delimited token equals 'arn') and, in that case, uses the value directly
as the resource; bare key IDs keep the existing 'key/${...}' construction. The
create-new-key and AWS_MANAGED_KEY paths are unaffected.
aws-cdk-automation
enabled auto-merge
August 22, 2026 06:59
lemon0333
requested a deployment
to
integ-approval
August 22, 2026 06:59 — with
GitHub Actions
Waiting
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1880 +/- ##
==========================================
+ Coverage 91.10% 91.13% +0.03%
==========================================
Files 80 80
Lines 12205 12205
Branches 1742 1744 +2
==========================================
+ Hits 11119 11123 +4
+ Misses 1050 1046 -4
Partials 36 36
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fixes #921
Description
FileAssetsBucketKmsKeyId's parameter description explicitly allows either a KMS key ID or a full key ARN. However, the bootstrap template unconditionally built the KMS resource ARN for theFilePublishingRoleDefaultPolicyas:When a (cross-account) key ARN is passed as the parameter value, this produces a malformed nested ARN —
arn:...:key/arn:aws:kms:...— and therefore an invalid IAM policy statement, so the file publishing role can't use the key.This adds a CFN
HasCustomKmsKeyArncondition that detects the ARN form by checking whether the first:-delimited token of the value isarn(Fn::Equals+Fn::Select+Fn::Split). When the value is already an ARN it is used verbatim as the resource; a bare key ID keeps the existingarn:...:key/${...}construction. TheCreateNewKeyandAWS_MANAGED_KEYpaths are unchanged.Extended
bootstrap-template.test.tsto assert the new condition and the nestedFn::Ifon the KMS statement resource. Bootstrap template/api tests pass (58 tests).Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license