forked from azeezsalu/terraform-tutorial-reference-files
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnat gateway reference.tf
More file actions
96 lines (77 loc) · 2.27 KB
/
nat gateway reference.tf
File metadata and controls
96 lines (77 loc) · 2.27 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# allocate elastic ip. this eip will be used for the nat-gateway in the public subnet az1
resource "aws_eip" "eip_for_nat_gateway_az1" {
vpc =
tags = {
Name =
}
}
# allocate elastic ip. this eip will be used for the nat-gateway in the public subnet az2
resource "aws_eip" "eip_for_nat_gateway_az2" {
vpc =
tags = {
Name =
}
}
# create nat gateway in public subnet az1
resource "aws_nat_gateway" "nat_gateway_az1" {
allocation_id =
subnet_id =
tags = {
Name =
}
# to ensure proper ordering, it is recommended to add an explicit dependency
depends_on =
}
# create nat gateway in public subnet az2
resource "aws_nat_gateway" "nat_gateway_az2" {
allocation_id =
subnet_id =
tags = {
Name =
}
# to ensure proper ordering, it is recommended to add an explicit dependency
# on the internet gateway for the vpc.
depends_on =
}
# create private route table az1 and add route through nat gateway az1
resource "aws_route_table" "private_route_table_az1" {
vpc_id =
route {
cidr_block =
nat_gateway_id =
}
tags = {
Name =
}
}
# associate private app subnet az1 with private route table az1
resource "aws_route_table_association" "private_app_subnet_az1_route_table_az1_association" {
subnet_id =
route_table_id =
}
# associate private data subnet az1 with private route table az1
resource "aws_route_table_association" "private_data_subnet_az1_route_table_az1_association" {
subnet_id =
route_table_id =
}
# create private route table az2 and add route through nat gateway az2
resource "aws_route_table" "private_route_table_az2" {
vpc_id =
route {
cidr_block =
nat_gateway_id =
}
tags = {
Name =
}
}
# associate private app subnet az2 with private route table az2
resource "aws_route_table_association" "private_app_subnet_az2_route_table_az2_association" {
subnet_id =
route_table_id =
}
# associate private data subnet az2 with private route table az2
resource "aws_route_table_association" "private_data_subnet_az2_route_table_az2_association" {
subnet_id =
route_table_id =
}