TERRAFORM
Dynamic NLB subnet mapping
Create one public address per subnet while keeping the load balancer declaration compact.
dynamic "subnet_mapping" {
for_each = toset(local.public_subnets)
content {
subnet_id = subnet_mapping.value
allocation_id = aws_eip.nlb[
subnet_mapping.value
].id
}
}