Aws-cdk: VPC construct should allow using custom route table for many subnets

Created on 1 Oct 2019  路  7Comments  路  Source: aws/aws-cdk

Currently it's not possible to specify either the number of route tables or inject a custom route table to the VPC construct.

Use Case

When creating VPN or Peering connections together with the VPC it would be great when I can customise the route table. For me there is no drawback having only one for many subnets - it's less complex when modifying it.

Proposed Solution

Make it possible to set the route table per subnet. Currently it's readonly. Why?

const privateRouteTable = new CfnRouteTable(this, "privateRouteTable", {
    vpcId: vpc.vpcId
})

const selection = vpc.selectSubnets({
    subnetType: ec2.SubnetType.PRIVATE
});
for (const subnet of selection.subnets) {
    subnet.routeTable = privateRouteTable
}
@aws-cdaws-ec2 efforlarge feature-request p1

Most helpful comment

I second this use case. It would be nice to manage the route tables in VPC construct. Currently it's hard to get a list of created route tables.

All 7 comments

@rix0rrr Is this something you would support? In that case I could create a PR maybe.

Can you describe your use case a bit more? What are you trying to achieve?

It's more or less for convenience. Our vpc stack currently has 1 route table for all private and 1 for all public subnets. Which is enough imho since we use different subnets/az for making apps HA, nothing more. So routes will be always the same. It seems more effort to me to mange 1 table per subnet when it comes to peering connections, vpns and so on. Also I'm having a problem switching to cdk managed vpc stacks currently since cdk would drop my existing tables and will add new tables that won't have routes for already existing peerings and vpns. By adding my own custom table I can name it like my already existing table (same logical id) and routes will be kept.

@rix0rrr I still could provide some code here if this would be fine for you. If you don't like it you should close this.

I second this use case. It would be nice to manage the route tables in VPC construct. Currently it's hard to get a list of created route tables.

@maschinetheist Last workaround I've tried was deleting the elements in the tree. This is now officially possible with #1408

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nzspambot picture nzspambot  路  3Comments

artyom-melnikov picture artyom-melnikov  路  3Comments

ababra picture ababra  路  3Comments

cybergoof picture cybergoof  路  3Comments

peterdeme picture peterdeme  路  3Comments