简体   繁体   中英

How can I remove resources from a CfnInclude imported CloudFormation stack?

I'm importing an existing Cloudformation stack into CDK using the method described in the AWS documentation .

The imported stack contains resources which I want to remove from AWS, so I'm looking for some delete/remove method in the imported cfnInclude:

    const cfnInclude = new cfn_inc.CfnInclude(this, 'Template', { 
      templateFile: 'ExistingTemplate.json'
    });
    // I'm looking for a method like this:
    // cfnInclude.remove('MyResourceName');  

Is it possible to do this somehow?

Call tryRemoveChild on the underlying Node to remove a child construct by name.

const success = cfnInclude.node.tryRemoveChild('MyFunctionToRemove');  // returns boolean

Note this is escape hatch functionality available to all Construct subclasses, not anything specific to CfnInclude.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM