-
Notifications
You must be signed in to change notification settings - Fork 0
/
subnets.tf
30 lines (25 loc) · 886 Bytes
/
subnets.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
# deploy subnets
#----------------------------------------------------
# deploy the public subnets
resource "aws_subnet" "public_subnets" {
for_each = var.public_subnets
vpc_id = aws_vpc.vpc.id
cidr_block = cidrsubnet(var.vpc_cidr, 8, each.value + 100)
availability_zone = tolist(data.aws_availability_zones.available.names)[each.value]
map_public_ip_on_launch = var.auto_ipv4
tags = {
Name = "${var.app_name}-${each.key}"
Subnet = "Public"
}
}
# deploy the private subnets
resource "aws_subnet" "private_subnets" {
for_each = var.private_subnets
vpc_id = aws_vpc.vpc.id
cidr_block = cidrsubnet(var.vpc_cidr, 8, each.value + 1)
availability_zone = tolist(data.aws_availability_zones.available.names)[each.value]
tags = {
Name = "${var.app_name}-${each.key}"
Subnet = "Private"
}
}