-
Notifications
You must be signed in to change notification settings - Fork 17
/
vpc.tf
59 lines (42 loc) · 1.12 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
resource "aws_vpc" "main" {
cidr_block = "172.20.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
instance_tenancy = "default"
tags = local.global_tags
}
resource "aws_default_security_group" "default" {
vpc_id = aws_vpc.main.id
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = local.global_tags
}
resource "aws_subnet" "sn_az" {
count = length(local.availability_zones)
availability_zone = local.availability_zones[count.index]
vpc_id = aws_vpc.main.id
map_public_ip_on_launch = false
cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 5, count.index+1)
tags = local.global_tags
}
resource "aws_internet_gateway" "igw" {
vpc_id = aws_vpc.main.id
tags = local.global_tags
}
resource "aws_route_table" "rt" {
vpc_id = aws_vpc.main.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.igw.id
}
tags = local.global_tags
}
resource "aws_route_table_association" "rt_assoc" {
count = length(aws_subnet.sn_az)
route_table_id = aws_route_table.rt.id
subnet_id = aws_subnet.sn_az[count.index].id
}