The state file just doesn’t track the dynamic keys properly. Syntax keeps breaking on the map conversion. We’re migrating queue configurations from the admin UI into the CX as Code provider and trying to automate the rollout. The YAML file holds the queue names and routing rules, but the for_each block keeps choking during the plan phase. We’ve tried parsing it with yamldecode and passing the result directly to the genesyscloud_routing_queue resource. It’s strange how the admin UI handles these batches fine, but the provider rejects the complex types.
Here’s the HCL block we’re working with:
resource "genesyscloud_routing_queue" "analytics_queues" {
for_each = yamldecode(file("queues.yaml"))
name = each.value.name
routing {
strategy = each.value.strategy
}
}
The YAML structure looks standard enough:
queue_a:
name: "Priority Support"
strategy: "longest_idle_agent"
queue_b:
name: "General Inquiries"
strategy: "most_available"
Terraform throws this error every time:
Error: Invalid for_each argument
on main.tf line 12:
A map or set of strings must be provided for for_each.
We’ve also attempted wrapping the YAML output in toset(keys(yamldecode(...))) and using nested maps. The provider still expects a flat string set for the keys. Just need the exact HCL syntax that stops the validator from complaining. Running the plan again tomorrow morning to see if a provider version bump fixes it.