forked from futurice/terraform-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subnets.tf
35 lines (27 loc) · 1.09 KB
/
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
31
32
33
34
35
data "aws_availability_zones" "available" {}
resource "aws_subnet" "private_subnet" {
count = length(var.private_subnet_cidrs)
vpc_id = aws_vpc.msk_vpc.id
cidr_block = element(split(",", join(",", var.private_subnet_cidrs)), count.index)
availability_zone = data.aws_availability_zones.available.names[count.index]
tags = merge(
local.common-tags,
map(
"Name", "MSK-${lower(var.environment)}-private-subnet-${count.index + 1}",
"Description", "${lower(var.environment)} private subnet - ${count.index + 1}"
)
)
}
resource "aws_subnet" "public_subnet" {
count = length(var.public_subnet_cidrs)
vpc_id = aws_vpc.msk_vpc.id
cidr_block = element(split(",", join(",", var.public_subnet_cidrs)), count.index)
availability_zone = data.aws_availability_zones.available.names[count.index]
tags = merge(
local.common-tags,
map(
"Name", "msk-${lower(var.environment)}-public-subnet-${count.index + 1}",
"Description", "${lower(var.environment)} private subnet - ${count.index + 1}"
)
)
}