question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[cloudformation] NestedStack doesn't have defaultChild

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
edisongustavocommented, Nov 2, 2020

I found the workaround for NestedStack. It is a simple matter of using the nestedStackResource property instead of node.defaultChild.

0reactions
github-actions[bot]commented, May 24, 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found