Home > Enterprise >  How to exclude default creation of route tables & its routes while creating VPC using the AWS CDK
How to exclude default creation of route tables & its routes while creating VPC using the AWS CDK

Time:12-13

I'm curious to know if we can exclude the default creation of any resources using L2 construct, specifically route tables & its routes. I want to explicitly create only two public & private route tables & its routes after that reference them in ec2.Vpc construct so it won't create on its own.

I have tried to explicitly write route tables & its routes using L1 constructs but faced blocker when I had to reference them to ec2.Vpc construct.

CodePudding user response:

You have two options if the public L2 APIs aren't enough:

  1. Additive approach: Build from scratch using L1 constructs. If you get stuck, take a look at the CDK source code. You can often reverse engineer what you need by looking at how the CDK does it.

  2. Subtractive approach: Start with the L2. Use escape hatch syntax to modify (node.findChild and addPropertyOverride) or delete (node.tryRemoveChild) child constructs.

  • Related