Skip to content
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

aws-cdk-lib: CfnInclude "parameters" description misleading #20905

Closed
jarettgross opened this issue Jun 28, 2022 · 8 comments · Fixed by #21001
Closed

aws-cdk-lib: CfnInclude "parameters" description misleading #20905

jarettgross opened this issue Jun 28, 2022 · 8 comments · Fixed by #21001
Assignees
Labels
aws-cdk-lib Related to the aws-cdk-lib package documentation This is a problem with documentation.

Comments

@jarettgross
Copy link

Describe the issue

The optional "parameters" prop states that if the prop is not provided, no parameters will be replaced. Additionally it states that if any parameter is not specified here, then it is left unmodified.

However, if the parameter has a "default" value in the template, then if that parameter is omitted from CfnInclude, the parameter is reset to the default. It is modified from what it originally was.

The wording of the documentation sounds misleading in this case. The template is unmodified, but the parameter itself is changed.

Links

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.cloudformation_include.CfnInclude.html#parameters

@jarettgross jarettgross added documentation This is a problem with documentation. needs-triage This issue or PR still needs to be triaged. labels Jun 28, 2022
@github-actions github-actions bot added the aws-cdk-lib Related to the aws-cdk-lib package label Jun 28, 2022
@peterwoodworth
Copy link
Contributor

I'm not seeing any inconsistent behaviors here - If I import a template, and then reference its parameter that has a default value, that default value will get carried over to the CDK stack. You're finding that a parameter with a default value isn't having that default value imported, correct?

@peterwoodworth peterwoodworth added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. documentation This is a problem with documentation. labels Jul 1, 2022
@jarettgross
Copy link
Author

The parameter is being set to the default value provided in the stack.

The issue I am seeing is that I have a stack that already exists in Cloudformation, with, say, a parameter called "MyRoleName" and a value of "TestData".

I am using CDK to import this existing stack so that CDK owns the stack. "MyRoleName" has a default value in the template of "OldData".

I then use CDK's CfnInclude to import the stack, but I leave my parameters block empty.

When deploying my CDK stack, "MyRoleName" then takes the value of "OldData". It overwrites the "TestData" value that previously existed.

From the wording in the documentation, it sounds like "TestData" would still be the value

Any parameters in the template that aren't specified here will be left unmodified.

This feels misleading because the value of "MyRoleName" is modified to the default value.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jul 1, 2022
@peterwoodworth
Copy link
Contributor

The parameter definition isn't being modified here - There's no way to know what the supplied value was for a parameter for a live stack. If you import a parameter with a default value, then i think most users would expect that your new stack would need to have the parameter supplied to override the default value.

Cfn docs on parameters https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html#parameters-section-structure-syntax.yaml, note how the parameter definition in your live stack and new stack is exactly the same.

@peterwoodworth peterwoodworth added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jul 2, 2022
@jarettgross
Copy link
Author

The parameter definition is not being modified -- that's correct, but the parameter value is being modified. I think adding that differentiation ("parameter definitions") in the docs would be helpful.

From these two lines in the docs:

(optional, default: no parameters will be replaced)
Any parameters in the template that aren't specified here will be left unmodified

To me, it reads as though the entire parameter, both definition and value, will be unmodified. I interpreted this to mean "if the parameter is not supplied then the parameter, both definition and value, are unmodified and not replaced"

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jul 2, 2022
@MCWoo
Copy link

MCWoo commented Jul 5, 2022

Hello, speaking for myself, perhaps this is an issue of not being intimately familiar with what CDK's CloudFormation's Include does that causes this confusion about what will be left unmodified means. But even if it said something like will retain its original parameter definition, I'm still not sure I'd expect it to revert to its original value. I would hope that it'd be similar to a CloudFormation deploy, which retains any parameters' values that are not specified. So the additional clarity would be helpful and I don't think it's harmful to add an extra sentence.

We ask about this documentation because it was related to a live outage to our customers that was thankfully easy to rectify. And though this may not be the sole issue, if the documentation were clearer we may have avoided such an outage. We are relatively new to CDK, and I would hope that the documentation would be helpful to our situation as we get up to speed on everything CDK related.

Thanks!

@peterwoodworth
Copy link
Contributor

I hear you guys that this is confusing to people who aren't very familiar with our services yet. Thanks for letting me know what the exact confusion is

Check out my PR, hope this provides the necessary clarity #21001 @MCWoo @jarettgross

@peterwoodworth peterwoodworth added documentation This is a problem with documentation. and removed needs-reproduction This issue needs reproduction. labels Jul 5, 2022
@jarettgross
Copy link
Author

Thanks for putting up the PR! That reads great and definitely helps clarify this situation. I appreciate you taking the time to consider and review this.

@mergify mergify bot closed this as completed in #21001 Jul 6, 2022
mergify bot pushed a commit that referenced this issue Jul 6, 2022
fixes #20905

----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Jul 6, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

iliapolo pushed a commit that referenced this issue Jul 6, 2022
fixes #20905

----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
daschaa pushed a commit to daschaa/aws-cdk that referenced this issue Jul 9, 2022
fixes aws#20905

----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws-cdk-lib Related to the aws-cdk-lib package documentation This is a problem with documentation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants