-
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): CFN version and description template sections were merged incorrectly #8251
fix(core): CFN version and description template sections were merged incorrectly #8251
Conversation
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
packages/@aws-cdk/core/lib/stack.ts
Outdated
case 'Description': | ||
// merge the two descriptions, with a newline in between | ||
template[section] = `${dest}\n${src}`; | ||
break; |
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.
This is a weird choice. I would say either error or destination wins.
In the case of CfnInclude, I think it's fair to say that if the description was altered after import, the altered description wins.
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.
This is not about "altering" - this is the case when Description
was provided from multiple places. See the test for this:
new CfnInclude(stack, 'T1', {
template: {
AWSTemplateFormatVersion: '2010-09-09',
Description: 'Test 1',
},
});
new CfnInclude(stack, 'T2', {
template: {
AWSTemplateFormatVersion: '2010-09-09',
Description: 'Test 2',
},
});
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.
Approving but with the strong request to apply a light refactor and include validation.
…incorrectly In the merge logic in Stack when rendering the template, it was mistakenly assumed that all CFN sections are objects. However, there are some sections, like Description and AWSTemplateFormatVersion, that are in fact strings. Add special logic for those cases in the merge functionality (multiple provided CFN versions are checked for being identical, and mutliple descriptions are merged together, with a newline in between). Fixes aws#8151
b084416
to
f009d29
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
When we changed the merging behavior in #8251, we forgot to account for the 'Rules' section. To prevent that error from happening again, let's default to merging objects without duplicates. Fixes #9485 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
When we changed the merging behavior in #8251, we forgot to account for the 'Rules' section. To prevent that error from happening again, let's default to merging objects without duplicates. Fixes #9485 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
In the merge logic in Stack when rendering the template,
it was mistakenly assumed that all CFN sections are objects.
However, there are some sections, like Description and AWSTemplateFormatVersion,
that are in fact strings.
Add special logic for those cases in the merge functionality
(multiple provided CFN versions are checked for being identical,
and multiple descriptions are merged together, with a newline in between).
Fixes #8151
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license