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

Nested stacks must be defined within scope of another non-nested stack error when using cfn.NestedStack #5686

Closed
davidsteed opened this issue Jan 7, 2020 · 2 comments · Fixed by #5729
Assignees
Labels
@aws-cdk/aws-cloudformation Related to AWS CloudFormation bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@davidsteed
Copy link

davidsteed commented Jan 7, 2020

Nested stacks must be defined within scope of another non-nested stack error when using cfn.NestedStack

Reproduction Steps

The example given in the documentation does not work
Copy and paste example https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-cloudformation
btw this does not compile without modification

constructor(scope: Construct, id: string, props: cfn.NestedStackProps)

must be changed to

constructor(scope: Construct, id: string, props?: cfn.NestedStackProps)

otherwise this does not compile

Error Log

Nested stacks must be defined within scope of another non-nested stack when running cdk synth

Environment

  • **CLI Version :1.19.0
  • Framework Version:
  • **OS :Mac
  • **Language :typescript

Other


This is 🐛 Bug Report

@davidsteed davidsteed added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 7, 2020
@davidsteed
Copy link
Author

I think this is related to #5594

@SomayaB SomayaB added the @aws-cdk/aws-cloudformation Related to AWS CloudFormation label Jan 7, 2020
eladb pushed a commit that referenced this issue Jan 9, 2020
Use `this` instead of `scope` and make `props` optional.

Fixes #5686
@eladb
Copy link
Contributor

eladb commented Jan 9, 2020

Thanks for the report. Indeed the sample in the README is broken.
Fix: #5729

@mergify mergify bot closed this as completed in #5729 Jan 9, 2020
mergify bot added a commit that referenced this issue Jan 9, 2020
Use `this` instead of `scope` and make `props` optional.

Fixes #5686

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudformation Related to AWS CloudFormation bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants