-
Notifications
You must be signed in to change notification settings - Fork 1
/
step3.tf
62 lines (49 loc) · 1.47 KB
/
step3.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
// Create Private Subnet
resource "aws_subnet" "pri_sub_1" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.4.0/22"
availability_zone = data.aws_availability_zones.available.names[0]
tags = {
Name = "private_subnet_1"
}
}
resource "aws_subnet" "pri_sub_2" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.8.0/22"
availability_zone = data.aws_availability_zones.available.names[1]
tags = {
Name = "private_subnet_2"
}
}
// Create Private Route Table
resource "aws_route_table" "route_table_pri_1" {
vpc_id = aws_vpc.main.id
tags = {
Name = "main_pri_1"
}
}
resource "aws_route_table" "route_table_pri_2" {
vpc_id = aws_vpc.main.id
tags = {
Name = "main_pri_2"
}
}
// Associate Route Table
resource "aws_route_table_association" "route_table_pri_association_1" {
subnet_id = aws_subnet.pri_sub_1.id
route_table_id = aws_route_table.route_table_pri_1.id
}
resource "aws_route_table_association" "route_table_pri_association_2" {
subnet_id = aws_subnet.pri_sub_2.id
route_table_id = aws_route_table.route_table_pri_2.id
}
resource "aws_route" "private_nat_1" {
route_table_id = aws_route_table.route_table_pri_1.id
destination_cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_nat_gateway.nat_gateway_1.id
}
resource "aws_route" "private_nat_2" {
route_table_id = aws_route_table.route_table_pri_2.id
destination_cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_nat_gateway.nat_gateway_2.id
}