-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute-tables.tf
63 lines (51 loc) · 1.65 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Create public route table & configure internet access
resource "aws_route_table" "public_rt" {
vpc_id = aws_vpc.project_vpc.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.vpc_igw.id
}
tags = {
Name = "public_rt"
}
}
# Associate public subnets with public route table
resource "aws_route_table_association" "public_rt_assoc" {
count = length(aws_subnet.public_subnets)
subnet_id = aws_subnet.public_subnets[count.index].id
route_table_id = aws_route_table.public_rt.id
}
# Create private route table for private app tier
resource "aws_route_table" "private_app_rt" {
vpc_id = aws_vpc.project_vpc.id
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_nat_gateway.nat_gw.id
}
tags = {
Name = "private-app-rt"
}
}
# Associate private app subnets with private route table
resource "aws_route_table_association" "private_app_rt_assoc" {
count = length(aws_subnet.private_app_subnets)
subnet_id = aws_subnet.private_app_subnets[count.index].id
route_table_id = aws_route_table.private_app_rt.id
}
# Create private route table for private database tier
resource "aws_route_table" "private_db_rt" {
vpc_id = aws_vpc.project_vpc.id
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_nat_gateway.nat_gw.id
}
tags = {
Name = "private-db-rt"
}
}
# Associate private database subnets with private route table
resource "aws_route_table_association" "private_db_rt_assoc" {
count = length(aws_subnet.private_db_subnets)
subnet_id = aws_subnet.private_db_subnets[count.index].id
route_table_id = aws_route_table.private_db_rt.id
}