https://pulumi.com logo
#general
Title
# general
l

lemon-art-23680

05/18/2023, 3:43 PM
Hi, I’m creating an EC2 instance and I want to change its routing table. The problem comes when I’m trying to override the default routing rule of the VPC (10.0.0.0/16 to local). Does anyone know how to create a routing table that overrides /changes the default setting? Note, I can’t change the default routing table of the VPC because I need it for other instances
The error says that routing table rule for 10.0.0.0/16 is already exist
h

hallowed-horse-57635

05/18/2023, 4:21 PM
the local route (cidr for vpc) is added for every route table and cannot be changed/updated. What are you trying to accomplish ? an example may be helpful
l

lemon-art-23680

05/18/2023, 4:23 PM
I’m creating an environment with a firewall (pfSense) and I have done that manually. I have changed the CIDR of the VPC for a specific subnet into the network interface of the FW.
h

hallowed-horse-57635

05/18/2023, 4:42 PM
But the 10.0.0.0/16 is the vpc cidr right? If that's so, any block that matches this space will be local and cannot be changed.
l

lemon-art-23680

05/18/2023, 4:47 PM
This is a subnet’s routing table inside the VPC 10.1.0.0/16. As you can see, I have changed the CIDR to the FWs interface
h

hallowed-horse-57635

05/18/2023, 4:52 PM
Ya the additional route should be more specific than the local route. May be you can share vpc cidr, subnet cidr and the specific route you are trying to add. Take a look at this if it helps. https://aws.amazon.com/blogs/aws/inspect-subnet-to-subnet-traffic-with-amazon-vpc-more-specific-routing/
l

lemon-art-23680

05/18/2023, 5:05 PM
Here is the code that I’m using: internet_route_table = ec2.RouteTable(“route_table_name”, vpc_id=self.vpc.id, routes=[ ec2.RouteTableRouteArgs(cidr_block=f’10.1.0.0/16’, network_interface_id=fw_interface.id), ec2.RouteTableRouteArgs(cidr_block=‘0.0.0.0/0’, network_interface_id=fw_interface.id), ], tags={‘Name’: “route_table_name”}) error creating Route in Route Table (rtb-08706f685e5305d9b) with destination (10.1.0.0/16): RouteAlreadyExists: The route identified by 10.1.0.0/16 already exists.
And thanks for the article, I’ll try to understand how to fix that code according
h

hallowed-horse-57635

05/18/2023, 6:32 PM
Welcome. If u can share the vpc cidr and the subnet cidr it will be helpful. And to try, change the route to 10.1.0.0/17.
l

lemon-art-23680

05/21/2023, 7:54 AM
The VPC CIDR is 10.1.0.0/16 Subnet A - 10.1.1.0/24 Subnet B - 10.1.2.0/24 I thought maybe to change the routing table after its creation but I don’t know if pulumi works like that. Step 1 - Create routing table Step 2 - Get the new routing table Step 3 - Change the record of 10.1.0.0/16 -> local to 10.1.0.0/16 -> FW interface
h

hallowed-horse-57635

05/21/2023, 2:15 PM
as mentioned earlier, the default entry of the route 10.1.0.0/16 (which corresponds to the VPC CIDR) cannot be changed from local. if the intention is to route all outbound traffic to the fw interface, then the 0.0.0.0/0 pointing to the eni will suffice. OR If you want to inspect INTER SUBNET traffic, then the route entries should be the SUBNET CIDR (example 10.1.2.0/24 which is more specific than the VPC CIDR) pointing to the eni. For Pulumi's behavior, if you make a change to a rule, it should be able to just update the rule. You dont typically add the default local rule in the Pulumi code as its always present. You only add new additional rules. Hope all this makes sense. Else if you are open for consulting, we can help you. DM me if required. Thanks
9 Views