-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnat.tf
40 lines (33 loc) · 1018 Bytes
/
nat.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
# nat gw
resource "aws_eip" "nat" {
vpc = true
}
resource "aws_nat_gateway" "nat-gw" {
allocation_id = "${aws_eip.nat.id}"
subnet_id = "${aws_subnet.main-public-1.id}"
depends_on = ["aws_internet_gateway.main-gw"]
}
# VPC setup for NAT
resource "aws_route_table" "main-private" {
vpc_id = "${aws_vpc.main.id}"
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = "${aws_nat_gateway.nat-gw.id}"
}
tags {
Name = "main-private-1"
}
}
# route associations private
resource "aws_route_table_association" "main-private-1-a" {
subnet_id = "${aws_subnet.main-private-1.id}"
route_table_id = "${aws_route_table.main-private.id}"
}
resource "aws_route_table_association" "main-private-2-a" {
subnet_id = "${aws_subnet.main-private-2.id}"
route_table_id = "${aws_route_table.main-private.id}"
}
resource "aws_route_table_association" "main-private-3-a" {
subnet_id = "${aws_subnet.main-private-3.id}"
route_table_id = "${aws_route_table.main-private.id}"
}