-
Notifications
You must be signed in to change notification settings - Fork 0
/
route_tables.tf
49 lines (46 loc) · 1.74 KB
/
route_tables.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
resource "aws_route_table" "public_route_table" {
vpc_id = aws_vpc.main.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.gateway.id
}
tags = {
Name = "public_subnet_route_table"
}
}
resource "aws_route_table" "private_route_table" {
vpc_id = aws_vpc.main.id
tags = {
Name = "private_subnet_route_table"
}
}
# Route in the private route table to direct traffic through the NAT Gateway
resource "aws_route" "private_route" {
route_table_id = aws_route_table.private_route_table.id
destination_cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_nat_gateway.nat_gateway.id
}
resource "aws_route_table_association" "rt_associate_public_subnet_1" {
subnet_id = aws_subnet.public_subnet_1.id
route_table_id = aws_route_table.public_route_table.id
}
resource "aws_route_table_association" "rt_associate_public_subnet_2" {
subnet_id = aws_subnet.public_subnet_2.id
route_table_id = aws_route_table.public_route_table.id
}
resource "aws_route_table_association" "rt_associate_public_subnet_3" {
subnet_id = aws_subnet.public_subnet_3.id
route_table_id = aws_route_table.public_route_table.id
}
resource "aws_route_table_association" "rt_associate_private_subnet_1" {
subnet_id = aws_subnet.private_subnet_1.id
route_table_id = aws_route_table.private_route_table.id
}
resource "aws_route_table_association" "rt_associate_private_subnet_2" {
subnet_id = aws_subnet.private_subnet_2.id
route_table_id = aws_route_table.private_route_table.id
}
resource "aws_route_table_association" "rt_associate_private_subnet_3" {
subnet_id = aws_subnet.private_subnet_3.id
route_table_id = aws_route_table.private_route_table.id
}