-
Notifications
You must be signed in to change notification settings - Fork 3
/
vpc.tf
56 lines (45 loc) · 1.31 KB
/
vpc.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
resource "aws_vpc" "titus" {
cidr_block = "30.0.0.0/16"
enable_dns_support = "true"
enable_dns_hostnames = "true"
}
resource "aws_subnet" "private_subnet_1" {
vpc_id = "${aws_vpc.titus.id}"
cidr_block = "30.0.100.0/24"
}
resource "aws_subnet" "public_subnet_1" {
vpc_id = "${aws_vpc.titus.id}"
cidr_block = "30.0.1.0/24"
}
resource "aws_internet_gateway" "internet_gw" {
vpc_id = "${aws_vpc.titus.id}"
}
resource "aws_route_table" "public_route_table" {
vpc_id = "${aws_vpc.titus.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.internet_gw.id}"
}
}
resource "aws_main_route_table_association" "vpc_route_table" {
vpc_id = "${aws_vpc.titus.id}"
route_table_id = "${aws_route_table.public_route_table.id}"
}
resource "aws_eip" "nat" {
vpc = true
}
resource "aws_nat_gateway" "nat" {
allocation_id = "${aws_eip.nat.id}"
subnet_id = "${aws_subnet.public_subnet_1.id}"
}
resource "aws_route_table" "private_route_table" {
vpc_id = "${aws_vpc.titus.id}"
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = "${aws_nat_gateway.nat.id}"
}
}
resource "aws_route_table_association" "private_route_table" {
subnet_id = "${aws_subnet.private_subnet_1.id}"
route_table_id = "${aws_route_table.private_route_table.id}"
}