(@aws-cdk/aws-ec2-alpha): vpc.addInternetGateway cannot handle multiple subnets with shared routetable #33672
Labels
@aws-cdk/aws-ec2
Related to Amazon Elastic Compute Cloud
bug
This issue is a bug.
effort/medium
Medium work item – several days of effort
p1
Describe the bug
If a VPC has 2 public subnets that share a single routing table, calling
vpc.addInternetGateway
with no options will attempt to add a route to the IGW to the route table for each subnet. This causes the cloudformation update to fail with a message like:It is possible to work around this by using seperate route tables for each subnet and whilst it's generally good practice to use one route table per subnet, shared route tables are legal.
It'a also possible to manually supplying single subnet to
vpc.addInternetGateway
, but it looks confusing semantically.Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
That the vpc.addInternetGateway should not try to add identical routes to the same routetable.
Current Behavior
That the vpc.addInternetGateway tries to add identical routes to the same routetable.
Reproduction Steps
Possible Solution
As
vpc.addInternetGateway
internally iterates over subnets, and the method it uses internally isvpc.addDefaultInternetRoute
, I'm not sure where the cleanest place to fix this is.Maybe
addInternetGateway
should iterate the subnets to produce a unique list of route tables, andaddDefaultInternetRoute
should operate on route tables not subnets, as semantically the route is added to the table, not the subnet. You would need some way of tellingaddDefaultInternetRoute
if it needed to added optional IPv6 routes as well.Here is very niave approach:
Additional Information/Context
No response
CDK CLI Version
2.1000.3
Framework Version
No response
Node.js Version
v20.13.1
OS
OSX 15.3.1
Language
TypeScript
Language Version
TypeScript 5.6.3
Other information
No response
The text was updated successfully, but these errors were encountered: