Reputation: 3256
I have the following code:
resource "aws_ec2_transit_gateway_route_table" "non_default" {
transit_gateway_id = "${aws_ec2_transit_gateway.tgw.id}"
}
resource "aws_ec2_transit_gateway_route_table_association" "non_default_association" {
transit_gateway_attachment_id = "${aws_vpn_connection.tgw-vpn-attachment.transit_gateway_attachment_id}"
transit_gateway_route_table_id = "${aws_ec2_transit_gateway_route_table.non_default.id}"
depends_on = ["aws_vpn_connection.tgw-vpn-attachment"]
}
# Name default route table — This is not working either.
resource "aws_default_route_table" "default" {
default_route_table_id = "${aws_ec2_transit_gateway.tgw.id}"
tags = {
Name = "HelloWorld"
}
}
I want to associate the VPN gateway attachment to the non-default route table. But when I run the above code it adds it to the default route table? I need a default route table and don’t want to disable it. How can I achieve the above results?
Also when I try to add a name tag to the default route table that is not working as well.
Upvotes: 2
Views: 2429
Reputation: 5645
You can change the default propagation route table for an attachment. Make sure that you follow all the steps below.
After you enable propagation, the routes should appear in the specified route table instead of the default one.
aws_ec2_transit_gateway_route_table_propagation
Enables the specified attachment to propagate routes to the specified propagation route table.
resource "aws_ec2_transit_gateway_route_table_association" "association" {
transit_gateway_attachment_id = "${aws_vpn_connection.tgw-vpn-attachment.transit_gateway_attachment_id}"
transit_gateway_route_table_id = "${aws_ec2_transit_gateway_route_table.non_default.id}"
}
resource "aws_ec2_transit_gateway_route_table_propagation" "propagation" {
transit_gateway_attachment_id = "${aws_vpn_connection.tgw-vpn-attachment.transit_gateway_attachment_id}"
transit_gateway_route_table_id = "${aws_ec2_transit_gateway_route_table.non_default.id}"
}
Upvotes: 1