Terraform Genesys Provider: for_each with YAML data source for Queues

Hey folks,

I’ve been wrestling with a Terraform setup for a client who wants to manage their queue structure via a YAML file rather than hardcoding resources. The idea is clean-read a YAML list of queues, loop through it with for_each, and spin up the resources in Genesys Cloud.

The YAML looks standard enough:

queues:
 - name: "Support US"
 description: "US Support Queue"
 media_type: "voice"
 - name: "Sales NA"
 description: "North America Sales"
 media_type: "voice"

I’m using the yaml data source to parse this into a map so for_each can iterate over it. Here’s the gist of the resource block:

data "yaml" "queue_config" {
 filename = "./queues.yaml"
}

resource "genesyscloud_routing_queue" "queue" {
 for_each = data.yaml.queue_config.queues
 
 name = each.value.name
 description = each.value.description
 media_types = [each.value.media_type]
}

The plan phase looks perfect. Terraform sees the two distinct resources and wants to create them. But when I run apply, it bombs out with a 409 Conflict error on the second queue. The error message is vague, just saying “Conflict” with no specific reason from the API side.

I’ve checked the API docs for POST /api/v2/routing/queues, and it seems like the request payload is valid. I can manually create these queues via Postman without issue. Is there a race condition in the Terraform provider where it doesn’t wait for the first resource to fully propagate before attempting the second? Or am I missing a dependency declaration?

I’ve tried adding depends_on to a dummy resource, but that feels like a hack. Anyone else run into this with for_each and the Genesys provider? It’s driving me nuts because the YAML approach works fine for users, just not queues.

Appreciate any pointers.