Terraform 0.12 dynamic block for subnet

I am wondering, is it possible to use a dynamic block for aws_subnet resource?
if so, could you send me an example?
I tried it, but I got an error.The argument “cidr_block” is required, but no definition was found.
Blocks of type “cidr_block” are not expected here.
resource “aws_subnet” “subnetp” {
vpc_id = aws_vpc.vpc22.id
map_public_ip_on_launch = true
availability_zone = data.aws_availability_zones.available.names[1]

dynamic “cidr_block” {
for_each = [for cidrblock in var.cidr_blocks_subnet: {
cidr_block = cidrblock.CidrBlock
name = cidrblock.Name
}]
content {
cidr_block = cidr_block.value.cidr_block
tags = merge(map(“Name”, cidr_block.value.name), var.default_tags)
}
}
}

Hi @pzowghi,

The cidr_block argument for aws_subnet expects a single string, so none of Terraform’s repetition constructs are really appropriate for it.

Could you share a little more about your underlying goal? If you can describe the problem you want to solve separately from what you tried in order to solve it I might be able to offer an alternative approach.

I have 6 subnets like this, I want to prevent to create 6 aws_subnet resources.
how I can use one or two subnets for all 6 subnets?
thank you