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:
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.
Subtractive approach: Start with the L2. Use escape hatch syntax to modify (
node.findChild
andaddPropertyOverride
) or delete (node.tryRemoveChild
) child constructs.