Hit a weird validation error while trying to spin up a batch of queues from a YAML variable file. The setup is pretty standard for our infra-as-code pipeline, but the for_each loop is choking on the type conversion.
I’ve got a variables.tf that expects a map(object) for the queue configs. The YAML file loads fine into the state, but when Terraform tries to iterate, it throws a type mismatch. It seems like the YAML parser is handing me a list of objects instead of a map, even though I’m explicitly casting it in the root module.
Here’s the relevant snippet from main.tf:
resource "genesyscloud_routing_queue" "queues" {
for_each = var.queue_configs
name = each.value.name
description = each.value.desc
}
And the variable definition:
variable "queue_configs" {
type = map(object({
name = string
desc = string
}))
}
The error payload looks like this:
Error: Inappropriate value for variable "queue_configs": element "queue_1": attribute "name": string required.
I’ve tried wrapping the YAML load in a toset or tomap function, but that just breaks the iteration logic further. Is there a specific way to flatten or transform a YAML array into a Terraform map for for_each? Running Terraform 1.5.7 with the latest Genesys provider.