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)
}
}
}