These are my route definitions:
# Routing tables to route traffic for Private Subnet
resource "aws_route_table" "private" {
count = var.az_count
vpc_id = aws_vpc.vpc.id
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = element(aws_nat_gateway.gw.*.id, count.index)
}
route {
cidr_block = "10.250.0.0/23"
network_interface_id = aws_network_interface.eni_vpn01.id
}
tags = merge(
{ "Name" = "${var.environment}-${data.aws_availability_zones.available.names[count.index]}-rt-private" },
var.default_tags,
{"eo:ops:type" = "networking"}
)
}
#Route for Internet Gateway
resource "aws_default_route_table" "main" {
default_route_table_id = aws_vpc.vpc.default_route_table_id
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_internet_gateway.ig.id
}
tags = merge(
{ "Name" = "${var.environment}-rt-public" },
var.default_tags,
{"eo:ops:type" = "networking"}
)
}
Here is output of a run.
# aws_default_route_table.main will be updated in-place
~ resource "aws_default_route_table" "main" {
id = "rtb-048986295f3176afa"
~ route = [
+ {
+ cidr_block = "0.0.0.0/0"
+ core_network_arn = ""
+ destination_prefix_list_id = ""
+ egress_only_gateway_id = ""
+ gateway_id = ""
+ instance_id = ""
+ ipv6_cidr_block = ""
+ nat_gateway_id = "igw-0eb25ccd5ca0e25bf"
+ network_interface_id = ""
+ transit_gateway_id = ""
+ vpc_endpoint_id = ""
+ vpc_peering_connection_id = ""
},
- {
- cidr_block = "0.0.0.0/0"
- core_network_arn = ""
- destination_prefix_list_id = ""
- egress_only_gateway_id = ""
- gateway_id = "igw-0eb25ccd5ca0e25bf"
- instance_id = ""
- ipv6_cidr_block = ""
- nat_gateway_id = ""
- network_interface_id = ""
- transit_gateway_id = ""
- vpc_endpoint_id = ""
- vpc_peering_connection_id = ""
},
]
# aws_route_table.private[0] will be updated in-place
~ resource "aws_route_table" "private" {
id = "rtb-05663bf0dfd235ee7"
~ route = [
- {
- carrier_gateway_id = ""
- cidr_block = "0.0.0.0/0"
- core_network_arn = ""
- destination_prefix_list_id = ""
- egress_only_gateway_id = ""
- gateway_id = ""
- instance_id = ""
- ipv6_cidr_block = ""
- local_gateway_id = ""
- nat_gateway_id = "nat-0247c9d9ea5115e39"
- network_interface_id = ""
- transit_gateway_id = ""
- vpc_endpoint_id = ""
- vpc_peering_connection_id = ""
},
+ {
+ carrier_gateway_id = ""
+ cidr_block = "10.250.0.0/23"
+ core_network_arn = ""
+ destination_prefix_list_id = ""
+ egress_only_gateway_id = ""
+ gateway_id = ""
+ instance_id = ""
+ ipv6_cidr_block = ""
+ local_gateway_id = ""
+ nat_gateway_id = ""
+ network_interface_id = "eni-0f1229f477f2357e7"
+ transit_gateway_id = ""
+ vpc_endpoint_id = ""
+ vpc_peering_connection_id = ""
},
- {
- carrier_gateway_id = ""
- cidr_block = "10.250.0.0/23"
- core_network_arn = ""
- destination_prefix_list_id = ""
- egress_only_gateway_id = ""
- gateway_id = ""
- instance_id = "i-001701ea138a13f54"
- ipv6_cidr_block = ""
- local_gateway_id = ""
- nat_gateway_id = ""
- network_interface_id = "eni-0f1229f477f2357e7"
- transit_gateway_id = ""
- vpc_endpoint_id = ""
- vpc_peering_connection_id = ""
},
+ {
+ carrier_gateway_id = null
+ cidr_block = "0.0.0.0/0"
+ core_network_arn = null
+ destination_prefix_list_id = null
+ egress_only_gateway_id = null
+ gateway_id = null
+ instance_id = null
+ ipv6_cidr_block = null
+ local_gateway_id = null
+ nat_gateway_id = "nat-0247c9d9ea5115e39"
+ network_interface_id = null
+ transit_gateway_id = null
+ vpc_endpoint_id = null
+ vpc_peering_connection_id = null
},
]
# aws_route_table.private[1] will be updated in-place
~ resource "aws_route_table" "private" {
id = "rtb-01869968b33811cca"
~ route = [
- {
- carrier_gateway_id = ""
- cidr_block = "0.0.0.0/0"
- core_network_arn = ""
- destination_prefix_list_id = ""
- egress_only_gateway_id = ""
- gateway_id = ""
- instance_id = ""
- ipv6_cidr_block = ""
- local_gateway_id = ""
- nat_gateway_id = "nat-09cb92ac75a925a43"
- network_interface_id = ""
- transit_gateway_id = ""
- vpc_endpoint_id = ""
- vpc_peering_connection_id = ""
},
+ {
+ carrier_gateway_id = ""
+ cidr_block = "10.250.0.0/23"
+ core_network_arn = ""
+ destination_prefix_list_id = ""
+ egress_only_gateway_id = ""
+ gateway_id = ""
+ instance_id = ""
+ ipv6_cidr_block = ""
+ local_gateway_id = ""
+ nat_gateway_id = ""
+ network_interface_id = "eni-0f1229f477f2357e7"
+ transit_gateway_id = ""
+ vpc_endpoint_id = ""
+ vpc_peering_connection_id = ""
},
- {
- carrier_gateway_id = ""
- cidr_block = "10.250.0.0/23"
- core_network_arn = ""
- destination_prefix_list_id = ""
- egress_only_gateway_id = ""
- gateway_id = ""
- instance_id = "i-001701ea138a13f54"
- ipv6_cidr_block = ""
- local_gateway_id = ""
- nat_gateway_id = ""
- network_interface_id = "eni-0f1229f477f2357e7"
- transit_gateway_id = ""
- vpc_endpoint_id = ""
- vpc_peering_connection_id = ""
},
+ {
+ carrier_gateway_id = null
+ cidr_block = "0.0.0.0/0"
+ core_network_arn = null
+ destination_prefix_list_id = null
+ egress_only_gateway_id = null
+ gateway_id = null
+ instance_id = null
+ ipv6_cidr_block = null
+ local_gateway_id = null
+ nat_gateway_id = "nat-09cb92ac75a925a43"
+ network_interface_id = null
+ transit_gateway_id = null
+ vpc_endpoint_id = null
+ vpc_peering_connection_id = null
},
]
I don’t get it why is it behaving like this. I am using latest TF AWS provider (4.30).