deployments/infrastructure/region/subnet.tf

44 lines
1.0 KiB
HCL

data "aws_availability_zones" "available" {
state = "available"
}
resource "aws_subnet" "public" {
count = 2
vpc_id = aws_vpc.network.id
cidr_block = cidrsubnet(var.network_cidr, 8, count.index + 1)
availability_zone = data.aws_availability_zones.available.names[count.index]
tags = {
Region = data.aws_region.current.name
Zone = "public"
}
}
resource "aws_subnet" "private" {
count = 2
vpc_id = aws_vpc.network.id
cidr_block = cidrsubnet(var.network_cidr, 8, count.index + 16)
availability_zone = data.aws_availability_zones.available.names[count.index]
tags = {
Region = data.aws_region.current.name
Zone = "private"
}
}
resource "aws_route_table_association" "public" {
count = 2
subnet_id = aws_subnet.public[count.index].id
route_table_id = aws_route_table.public.id
}
resource "aws_route_table_association" "private" {
count = 2
subnet_id = aws_subnet.private[count.index].id
route_table_id = aws_route_table.private[count.index].id
}