-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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): Stacks render CloudFormation elements in nested Stages #10156
Conversation
In current recommended CDK Pipelines usage, the construct tree looks like this: ``` App -> Stack1 -> Stage -> Stack2 -> Resource ``` It's an easy mistake to forget `Stack2` (or make it a generic `Construct` instead), in which case the hierachy looks like the one below and `Stack1` will render Resource in its CloudFormation template: ``` App -> Stack1 -> Stage -> Construct -> Resource ``` This case should not have been allowed in the first place: `Stage`s define a new assembly scope and so `Stack1` does not exist from the point of view of `Resource`. Change `Stack.of()` to fail to find `Stack1` in this case, so that it becomes illegal to define `Resource` in this position. Fixes #9792, relates to #9669.
new core.CfnResource(app, 'Resource', { | ||
type: 'Some::Resource', | ||
}); | ||
}, /No stack could be identified for the construct/); |
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 likely 'new to the CDK' error and the message for someone like that is a bit vague.
Either something a bit more clear to tell the user that they've done something incorrectly or an action to correct it may help.
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request will be updated from master 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 |
In current recommended CDK Pipelines usage, the construct tree looks
like this:
It's an easy mistake to forget
Stack2
(or make it a genericConstruct
instead), in which case the hierachy looks like the onebelow and
Stack1
will render Resource in its CloudFormation template:This case should not have been allowed in the first place:
Stage
sdefine a new assembly scope and so
Stack1
does not exist from thepoint of view of
Resource
.Change
Stack.of()
to fail to findStack1
in this case, sothat it becomes illegal to define
Resource
in this position.Fixes #9792, relates to #9669.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license