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

Removing constructs from a stack #4848

Closed
3p3r opened this issue Nov 5, 2019 · 2 comments
Closed

Removing constructs from a stack #4848

3p3r opened this issue Nov 5, 2019 · 2 comments
Assignees
Labels
@aws-cdk/core Related to core CDK functionality guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged.

Comments

@3p3r
Copy link
Contributor

3p3r commented Nov 5, 2019

❓ General Issue

The Question

I am trying to remove all auto generated CfnOutput constructs from my stack to save some space. I attempted to do this with an aspect, but wanted to see if there is a cleaner solution to achieve this. The question is really, how to remove children from stack's root node given a path? I found ways to add children but not removing them.

class StackOutputRemover {
  visit(node) {
    // See that we're dealing with a CfnBucket
    if (node instanceof cdk.CfnOutput) {
      // stackName = node.stack.stackName;
      const pathComponents = node.node.path.split(cdk.ConstructNode.PATH_SEP);
      assert.ok(pathComponents.length >= 2, 'invalid construct path found');
      // is path an immediate child of the stack (${stack}/${construct})?
      const isImmediate = pathComponents.length == 2;
      // these are user added constructs, return
      if (isImmediate) return;
      assert.ok(pathComponents.shift() === node.stack.stackName);
      const connector = '.node._children.';
      eval(`delete node.stack${connector}${pathComponents.join(connector)}`);
    }
  }
}

Environment

  • CDK CLI Version: 1.15.0 (build bdbe3aa)
  • Module Version: N/A
  • OS: Ubuntu 18.04
  • Language: JavaScript

Other information

I am using constructs and abstractions in the ecs-patterns module and noticed it auto generates CfnOutput constructs for my stack. I do not want them and want to be able to filter them if possible.

@3p3r 3p3r added the needs-triage This issue or PR still needs to be triaged. label Nov 5, 2019
@SomayaB SomayaB added guidance Question that needs advice or information. @aws-cdk/aws-ecs-patterns Related to ecs-patterns library labels Nov 5, 2019
@piradeepk piradeepk assigned rix0rrr and eladb and unassigned SoManyHs and piradeepk Nov 6, 2019
@pasieronen
Copy link

Related to #1408

@SomayaB SomayaB added @aws-cdk/core Related to core CDK functionality and removed @aws-cdk/aws-ecs-patterns Related to ecs-patterns library labels Nov 12, 2019
@eladb
Copy link
Contributor

eladb commented Jan 22, 2020

This was added is #5608

@eladb eladb closed this as completed Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

7 participants