fix(logs): emit root ARN in resource policy to prevent CloudFormation drift - #37954
Open
nithinnnv wants to merge 2 commits into
Open
fix(logs): emit root ARN in resource policy to prevent CloudFormation drift#37954nithinnnv wants to merge 2 commits into
nithinnnv wants to merge 2 commits into
Conversation
Author
|
@aws-cdk/aws-cdk-owners — gentle ping! Happy to address any feedback. |
This was referenced Jun 24, 2026
Collaborator
|
Hi @nithinnnv, As @krantboy reported #37797 (comment), CloudWatch Logs rejects ARN-format principals: I personally verified this with a bare CFN template (no CDK) — the root ARN is rejected, the bare account ID is accepted. But the bare ID is normalized to the ARN form on the resource side. Later when we deploy the same stack again, CloudFormation checks the resource state (normalized ARN) vs the template (bare account ID) and flags it as drift. I further discuss in the issue: #37797 (comment) |
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.
Issue # (if applicable)
Closes #37797.
Summary
convertArnPrincipalToAccountIdinaws-logs/lib/log-group.tswas emitting bare account IDs (e.g."211125612616") as thePrincipal.AWSvalue in CloudWatch Logs resource policies whengrantRead()oraddToResourcePolicy()is called with a cross-account principal.arn:aws:iam::211125612616:root) on the deployed resource. This mismatch causes drift detection to permanently flag every stack using these methods with a cross-account principal asDRIFTEDon every evaluation cycle.Test plan
aws-logs/test/loggroup.test.tsto assert root ARN formatgrantRead with cross-account role emits root ARN to prevent CloudFormation driftinteg.loggroup-grantread.tsto include a cross-accountArnPrincipalcase and regenerated snapshot —LogGroup2's resource policy shows"AWS":"arn:aws:iam::123456789012:root"