I am trying to automate queue provisioning using the nice_cxone Terraform provider. The goal is to create a queue and assign specific skills to it in a single apply cycle.
I have defined the queue resource and the skill resources separately. The skills are created first, which works fine. The issue arises when I try to reference those skills in the nice_cxone_queue resource using the skills block.
Here is the relevant :
resource "nice_cxone_queue" "support_queue" {
name = "Tier 1 Support"
skills {
for_each = var.skill_ids
name = each.value
}
}
When I run terraform apply, the provider throws a 400 Bad Request error. The error message is vague:
Error: POST https://api.cxone.com/api/v2/queues returned 400
Body: {"errors":[{"code":"bad_request","message":"Invalid skill configuration"}]}
I verified the skill IDs exist and are active. I also tried using the skill names instead of IDs, but the result is the same. The documentation for the provider is sparse on how to handle dynamic skill assignments.
I checked the raw API request using the Terraform debug logs. The payload sent to the API looks like this:
{
"name": "Tier 1 Support",
"skills": [
{"name": "billing"},
{"name": "technical"}
]
}
If I manually curl this payload to the API, it works. So the structure seems correct. The issue might be with how the provider handles the for_each loop or timing dependencies between the skill creation and queue creation.
Has anyone successfully mapped skills to queues using this provider? I am stuck on why the API rejects the valid-looking payload when called through Terraform. The provider version is 1.2.4. I have tried adding a depends_on clause pointing to the skill resources, but that did not help.