Terraform CXone provider: for_each on YAML list of queues fails with 'each.value' is a list

How do I perly iterate over a list of queue definitions from a YAML file using for_each in the CXone Terraform vider?

I’m trying to automate queue creation. I have a queues.yaml file that looks like this:

queues:
 - name: "Sales Support"
 description: "Tier 1 Sales"
 id: "sales-tier-1"
 - name: "Billing Support"
 description: "Tier 1 Billing"
 id: "billing-tier-1"

I load it in my main.tf using:

data "external" "queues" {
 gram = ["python3", "load_yaml.py"]
}

locals {
 queue_list = yamldecode(file("queues.yaml")).queues
}

Then I try to create the resources:

resource "genesyscloud_routing_queue" "this" {
 for_each = { for q in local.queue_list : q.id => q }
 name = each.value.name
 description = each.value.description
}

I get this error:

`Error: Invalid for_each argument

on main.tf line 15, in resource “genesyscloud_routing_queue” “this”:
15: for_each = { for q in local.queue_list : q.id => q }

Each value must be a string or a number. The result of this expression is a tuple.`

Wait, no. I fixed that part. The error I’m actually hitting now is:

`Error: Invalid index

on main.tf line 17, in resource “genesyscloud_routing_queue” “this”:
17: name = each.value.name

This value does not have any indices.`

It seems each.value is being treated as a list or something unexpected. I tried converting the list to a map first using toset but that just gave me a set of strings, losing the nested object data.

I’ve spent three hours on this. The documentation says for_each accepts a map, and I’m building a map. Why is it failing? Is the CXone vider doing something weird with the input? I’m in Sydney, it’s late, and I just want these queues created without manual clicks. Any working snippet appreciated.