[cloudformation] NestedStack doesn't have defaultChild
See original GitHub issueI get an undefined
object when I access the attribute defaultChild
from a NestedStack
’s node.
Reproduction Steps
I tried this code on https://play-with-cdk.com/
import * as cdk from '@aws-cdk/core';
import { CfnStack, NestedStack } from '@aws-cdk/aws-cloudformation';
// Keep the class name stable please
export class AppStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// Add your code here
var nestedStack = new NestedStack(this, 'MyNestedStack');
var cfn_nestedStack = (nestedStack.node.defaultChild) as CfnStack;
cfn_nestedStack.addPropertyOverride('TemplateURL', 'http://my-url.com');
}
}
What did you expect to happen?
The stack to be synthesized without errors and with the TemplateURL
parameter of the stack overriden.
What actually happened?
The synth crashes with this error:
TypeError: Cannot read property 'addPropertyOverride' of undefined
Environment
I have also tried it with Python and the same error happens.
- CLI Version : 1.59.0
- Framework Version: 1.59.0
- Node.js Version:
- OS : Ubuntu 18.04
- Language (Version): all
Other
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Working with nested stacks - AWS CloudFormation
Nested stacks are stacks created as part of other stacks. You create a nested stack within another stack by using the AWS::CloudFormation::Stack resource....
Read more >@aws-cdk/core - npm
When a resource from a parent stack is referenced by a nested stack, a CloudFormation parameter will automatically be added to the nested...
Read more >Create resources conditionally with CDK - Luciano Mammino
Learn how you can use Cloudformation conditions with CDK to be able to create resources using deploy-time conditions.
Read more >Cloudformation nested stack template ValidationError for child ...
So you have 2 options: Option 1: Export the value(s) you care ... But in this case, child template 2 does not depend...
Read more >How to Override Logical IDs of Resources in AWS CDK
In order to override the Logical ID of a resource in CDK we have to use the ... We set the resource's logical...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I found the workaround for
NestedStack
. It is a simple matter of using thenestedStackResource
property instead ofnode.defaultChild
.⚠️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.