feat: nat-gateways
This commit is contained in:
1 parent
b7b1653cc6
commit
e19d7fc053
11 files changed
+88
-53
No files matched your search
@@ -0,0 +1,32 @@
|
||||
# route_table.tf
|
||||
|
||||
resource "aws_route_table" "self" {
|
||||
for_each = local.subnets_attributes
|
||||
vpc_id = aws_vpc.self.id
|
||||
|
||||
dynamic "route" {
|
||||
for_each = each.value.default_route == "internet_gateway" ? toset([0]) : []
|
||||
content {
|
||||
cidr_block = "0.0.0.0/0"
|
||||
gateway_id = aws_internet_gateway.self[route.value].id
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "route" {
|
||||
for_each = startswith(each.value.default_route, "nat_gateway.") ? toset([trimprefix(each.value.default_route, "nat_gateway.")]) : []
|
||||
content {
|
||||
cidr_block = "0.0.0.0/0"
|
||||
nat_gateway_id = aws_nat_gateway.self[join("-", [route.value, each.value.availability_zone])].id
|
||||
}
|
||||
}
|
||||
|
||||
tags = {
|
||||
Name = join("-", compact([var.prefix, each.key]))
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "public" {
|
||||
for_each = local.subnets_attributes
|
||||
route_table_id = aws_route_table.self[each.key].id
|
||||
subnet_id = aws_subnet.self[each.key].id
|
||||
}
|
||||
Reference in new issue
Block a user