-
Notifications
You must be signed in to change notification settings - Fork 2
/
routing.tf
59 lines (51 loc) · 2.38 KB
/
routing.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* Public */
resource "aws_route_table" "public" {
count = length(data.aws_availability_zones.available.names)
vpc_id = aws_vpc.vpc.id
tags = merge(local.tags, { "Name" = "public_route_table_${terraform.workspace}_${count.index}" })
}
resource "aws_route_table_association" "public" {
count = length(data.aws_availability_zones.available.names)
subnet_id = aws_subnet.public[count.index].id
route_table_id = aws_route_table.public[count.index].id
}
resource "aws_route" "public_default" {
count = length(data.aws_availability_zones.available.names)
route_table_id = aws_route_table.public[count.index].id
gateway_id = aws_internet_gateway.internet.id
destination_cidr_block = "0.0.0.0/0"
}
/* Private */
resource "aws_route_table" "private" {
count = length(data.aws_availability_zones.available.names)
vpc_id = aws_vpc.vpc.id
tags = merge(local.tags, { "Name" = "private_route_table_${terraform.workspace}_${count.index}" })
}
resource "aws_route_table_association" "private" {
count = length(data.aws_availability_zones.available.names)
subnet_id = aws_subnet.private[count.index].id
route_table_id = aws_route_table.private[count.index].id
}
resource "aws_route" "private_default" {
count = length(data.aws_availability_zones.available.names)
route_table_id = aws_route_table.private[count.index].id
nat_gateway_id = var.single_nat_gw ? aws_nat_gateway.nat_gw[0].id : aws_nat_gateway.nat_gw[count.index].id
destination_cidr_block = "0.0.0.0/0"
}
/* Database */
resource "aws_route_table" "database" {
count = length(data.aws_availability_zones.available.names)
vpc_id = aws_vpc.vpc.id
tags = merge(local.tags, { "Name" = "database_route_table_${terraform.workspace}_${count.index}" })
}
resource "aws_route_table_association" "database" {
count = length(data.aws_availability_zones.available.names)
subnet_id = aws_subnet.database[count.index].id
route_table_id = aws_route_table.database[count.index].id
}
resource "aws_route" "database_default" {
count = length(data.aws_availability_zones.available.names)
route_table_id = aws_route_table.database[count.index].id
nat_gateway_id = var.single_nat_gw ? aws_nat_gateway.nat_gw[0].id : aws_nat_gateway.nat_gw[count.index].id
destination_cidr_block = "0.0.0.0/0"
}