-
Notifications
You must be signed in to change notification settings - Fork 24
/
routing_nat_instance.tf
39 lines (34 loc) · 1.15 KB
/
routing_nat_instance.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
# allow internet access to Application nodes through nat #1
resource "aws_route_table" "nat_instance_1" {
count = "${local.nat_instance ? 1 : 0}"
vpc_id = "${aws_vpc.project.id}"
route {
cidr_block = "0.0.0.0/0"
instance_id = "${aws_instance.nat_1.id}"
}
tags {
Name = "Application to Internet through Nat instance #1"
}
}
resource "aws_route_table_association" "app_1_subnet_to_nat_instance" {
count = "${local.nat_instance ? 1 : 0}"
route_table_id = "${aws_route_table.nat_instance_1.id}"
subnet_id = "${aws_subnet.private_app_1.id}"
}
# allow internet access to Application nodes through nat #2
resource "aws_route_table" "nat_instance_2" {
count = "${local.nat_instance_multi_az ? 1 : 0}"
vpc_id = "${aws_vpc.project.id}"
route {
cidr_block = "0.0.0.0/0"
instance_id = "${aws_nat_gateway.nat_2.id}"
}
tags {
Name = "Application to Internet through Nat instance #2"
}
}
resource "aws_route_table_association" "app_2_subnet_to_nat_instance" {
count = "${local.nat_instance_multi_az ? 1 : 0}"
route_table_id = "${aws_route_table.nat_instance_2.id}"
subnet_id = "${aws_subnet.private_app_2.id}"
}