I'm submitting a ...
What is the current behavior?
When i create a Subnet, and change the RouteTableAssociation to an existing route table, an unused route table is created along with the subnet.
What is the expected behavior (or behavior of feature suggested)?
I would like to be able to remove this route table or that cdk is smart enough to not create it
Please tell us about your environment:
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)
Subnet Subnet = new Subnet(this, "Subnet", SubnetProps.builder()
.withVpcId(vpc.getVpcId())
.withAvailabilityZone("eu-west-1b")
.withCidrBlock(String.format("10.%d.43.128/25", environmentId))
.build());
CfnSubnetRouteTableAssociation routeTableAssociation = (CfnSubnetRouteTableAssociation) subnet.getNode().tryFindChild("RouteTableAssociation");
routeTableAssociation.setRouteTableId(Fn.importValue(String.format("%s-nat-nat000", environment)));
CfnRouteTable cfnRouteTable = (CfnRouteTable) subnet.getNode().tryFindChild("RouteTable");
I'm not sure this counts as a bug.
Unfortunately, the Subnet construct right now is heavily tied to the Vpc construct, and supports exactly the features it needs.
This sounds like a feature request for an optional RouteTable input parameter to Subnet.
Not only in SubnetProps but also in subnetConfiguration so it can be used directly in the VPC construct.
Related to https://github.com/aws/aws-cdk/issues/5927
Most helpful comment
4308 RouteTable input would be appreciated.
Not only in SubnetProps but also in subnetConfiguration so it can be used directly in the VPC construct.