-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): throw on intrinsics in CFN update and create policies #31578
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Closes #27578, Closes #30740.
Reason for this change
cfn-include
only allows Intrinsics in resource update and create policies to wrap primitive values. If Intrinsics are included anywhere else,cfn-include
silently drops them.CDK's type system does not allow intrinsics in resource policies unless they define a primitive value.
cfn-include
adheres to this type system and drops any resource policies that use an intrinsic to define a complex value. This is an example of a forbidden use of intrinsics:This is forbidden because an intrinsic contains the
Count
property of this policy. CFN allows this, but CDK's type system does not permit it.Description of changes
cfn-include
will throw if any intrinsics break the type system, instead of silently dropping them.CDK's type system is a useful constraint around these resource update / create policies because it allows constructs that modify them, like autoscaling, to not be token-aware. Tokens are not resolved at synthesis time, so it makes it impossible to modify these with simple arithmetic if they contain tokens.
The CDK will never (or at least should not) generate a token that breaks this type system.
Thus, the only use-case for allowing these tokens is
cfn-include
. Supporting these customers would require the CDK type system to allow these, and thus CDK L2s should handle such cases; except, for L2 customers, this use-case does not happen. Explicitly reject templates that don't conform to this.Throwing here is a breaking change, so this is under a feature flag.
Additionally add a new property,
dehydratedResources
-- a list of logical IDs thatcfn-include
will not parse. Those resources still exist in the final template.This does not impact L2 users.
Description of how you validated changes
Unit testing.
Manually verified that this does not impact any L2s.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license