Skip to content

[cloudformation] NestedStack doesn't have defaultChild #11221

@edisongustavo

Description

@edisongustavo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-cloudformationRelated to AWS CloudFormationbugThis issue is a bug.effort/smallSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions