Terraform data source lookup by name failing with 404 on genesyscloud_routing_queue

We’re trying to reference an existing Genesys Cloud routing queue by name in our Terraform configuration to avoid hardcoding IDs. The queue definitely exists in the org, and I can see it in the UI.

Here’s the data source block:

data "genesyscloud_routing_queue" "support_queue" {
 name = "Global Support Tier 1"
}

When I run terraform plan, it fails with:

Error: 404 Not Found
 with data.genesyscloud_routing_queue.support_queue,
 on main.tf line 12, in data "genesyscloud_routing_queue" "support_queue":
 12: data "genesyscloud_routing_queue" "support_queue" {

I’ve verified the name matches exactly, including capitalization. I’ve also tried adding a label attribute just in case, but that didn’t help. The provider version is 1.0.0.

Is there a known issue with name-based lookups in the latest provider? Or do I need to use a different attribute to match existing resources? The docs aren’t clear on whether it searches by name, label, or both.

The terraform provider is likely hitting the API with a name that doesn’t match exactly. Genesys Cloud APIs are case-sensitive and whitespace-sensitive. “Global Support Tier 1” in the UI might actually be "Global Support Tier 1 " with a trailing space, or maybe “global support tier 1” in lowercase depending on how it was created via API.

The underlying API call is GET /api/v2/routing/queues/search. If you look at the docs:

“Search for routing queues by name. The search is case-insensitive but requires exact match on the name string provided.”

Wait, the docs say case-insensitive? Actually, the terraform provider sometimes wraps this. But more often, the issue is that the queue ID in the data source lookup fails because the queue isn’t fully provisioned or there’s a scope issue with the service account running terraform.

Try checking the raw API response first to see what names are actually returned. Use this curl command to debug the exact name string:

curl -X GET "https://api.mypurecloud.com/api/v2/routing/queues/search?name=Global%20Support%20Tier%201" \
 -H "Authorization: Bearer <TOKEN>" \
 -H "Content-Type: application/json"

If that returns empty, the name is definitely wrong. If it returns the queue, then the terraform provider might be having trouble with the name attribute parsing.

Also, check if your terraform state has an old ID cached. Sometimes terraform refresh helps, but usually you need to force the data source to re-read.

data "genesyscloud_routing_queue" "support_queue" {
 name = "Global Support Tier 1"
 
 # Force re-read if state is stale
 lifecycle {
 ignore_changes = [all]
 }
}

Actually, ignore_changes on all is bad practice. Just delete the state file for that data source or use terraform state rm data.genesyscloud_routing_queue.support_queue.

Another gotcha: if the queue is archived, it won’t show up in the search unless you include archived in the query. The terraform provider doesn’t expose an “include_archived” flag for the data source easily. Check if the queue is active.

I’ve seen this fail in Azure Functions too when the token scope didn’t include routing:queue:view. Make sure the OAuth client used by terraform has that scope.