fix(core): throw on intrinsics in CFN update and create policies#31578
fix(core): throw on intrinsics in CFN update and create policies#31578mergify[bot] merged 20 commits intomainfrom
Conversation
aws-cdk-automation
left a comment
There was a problem hiding this comment.
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.
aws-cdk-automation
left a comment
There was a problem hiding this comment.
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-includeonly allows Intrinsics in resource update and create policies to wrap primitive values. If Intrinsics are included anywhere else,cfn-includesilently drops them.CDK's type system does not allow intrinsics in resource policies unless they define a primitive value.
cfn-includeadheres 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
Countproperty of this policy. CFN allows this, but CDK's type system does not permit it.Description of changes
cfn-includewill 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-includewill 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