-
Notifications
You must be signed in to change notification settings - Fork 0
/
vpc.tf
67 lines (52 loc) · 1.34 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
57
58
59
60
61
62
63
64
65
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/20"
instance_tenancy = "default"
enable_dns_hostnames = true
enable_dns_support = true
tags = {
Name = "privatelink-poc-vpc"
}
}
resource "aws_subnet" "private" {
count = 3
vpc_id = aws_vpc.main.id
cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 4, count.index)
availability_zone = element(var.vpc_azs, count.index)
map_public_ip_on_launch = false
tags = {
Name = "privatelink-poc-private-${count.index}"
}
}
resource "aws_subnet" "public" {
count = 3
vpc_id = aws_vpc.main.id
cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 4, count.index + 4)
availability_zone = element(var.vpc_azs, count.index)
map_public_ip_on_launch = true
tags = {
Name = "privatelink-poc-public-${count.index}"
}
}
resource "aws_internet_gateway" "igw" {
vpc_id = aws_vpc.main.id
tags = {
Name = "privatelink-poc-igw"
}
}
resource "aws_eip" "natgw" {
count = 1
tags = {
Name = "privatelink-poc-natgw"
}
}
resource "aws_nat_gateway" "natgw" {
count = 1
allocation_id = aws_eip.natgw[0].id
subnet_id = aws_subnet.public[0].id
tags = {
Name = "privatelink-poc-natgw"
}
depends_on = [
aws_internet_gateway.igw
]
}