-
Notifications
You must be signed in to change notification settings - Fork 0
/
vpc.tf
53 lines (44 loc) · 1.27 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
resource "aws_vpc" "main" {
cidr_block = var.main_vpc_cidr
instance_tenancy = "default"
}
resource "aws_internet_gateway" "IGW" {
vpc_id = aws_vpc.main.id
}
resource "aws_subnet" "publicsubnets" {
vpc_id = aws_vpc.main.id
cidr_block = "${var.public_subnets}"
}
resource "aws_subnet" "privatesubnets" {
vpc_id = aws_vpc.main.id
cidr_block = "${var.private_subnets}"
}
resource "aws_route_table" "PublicRT" {
vpc_id = aws_vpc.main.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.IGW.id
}
}
resource "aws_route_table" "PrivateRT" {
vpc_id = aws_vpc.main.id
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_nat_gateway.NATgw.id
}
}
resource "aws_route_table_association" "PublicRTassociation" {
subnet_id = aws_subnet.publicsubnets.id
route_table_id = aws_route_table.PublicRT.id
}
resource "aws_route_table_association" "PrivateRTassociation" {
subnet_id = aws_subnet.privatesubnets.id
route_table_id = aws_route_table.PrivateRT.id
}
resource "aws_eip" "nateIP" {
vpc = true
}
resource "aws_nat_gateway" "NATgw" {
allocation_id = aws_eip.nateIP.id
subnet_id = aws_subnet.publicsubnets.id
}