I am trying to use the Genesys Cloud Terraform provider to provision multiple queues from a single YAML variable file. The goal is to avoid duplicating resource blocks. I have a file called queues.yaml that contains a list of queue configurations. I am using for_each in the resource block to iterate over this list. The problem is that Terraform throws an error about the type of the variable during the plan phase. It says the for_each value must be a map or set of strings, but my YAML file is producing a list of objects. I tried using local to convert the list to a map using the queue name as the key, but then the attributes inside the object are not accessible in the resource block. Here is the snippet I am working with:
variable "queues" {
type = any
}
locals {
queue_map = {
for q in var.queues : q.name => q
}
}
resource "genesyscloud_routing_queue" "queue" {
for_each = local.queue_map
name = each.value.name
description = each.value.description
}
The error message is Inappropriate value for attribute "for_each": element "name": string required.. I suspect the issue is how the YAML is being parsed into the Terraform state or how the any type is handling the nested structure. I have checked the provider documentation and it mentions using maps for for_each, but the examples are simple string-to-string mappings. My data is more complex with descriptions and wrap-up codes. I need to know the correct way to structure the YAML and the Terraform variable definition to make this work. I don’t want to hardcode the queues in the HCL file because the list changes frequently. I am using Terraform version 1.5 and the latest Genesys Cloud provider. Any help would be appreciated.