How should I properly to handle idempotent creation of Workforce Management Schedule Groups via Genesys Cloud API?
Automated pipeline using Terraform provider v2.1.0 and GC CLI v1.5.4 fails during environment promotion. Target environment: Production.
Terraform configuration:
resource "genesyscloud_wfm_schedulegroup" "shift_supervisor" {
name = "Shift Supervisor Group"
description = "Auto-generated schedule group for shift supervisors"
assignment_settings {
schedule_type = "SCHEDULED"
}
}
Deployment log shows successful ID retrieval from state file, but API call returns 400.
Error: POST /api/v2/wfm/schedulegroups
Status: 400 Bad Request
Message: “A schedule group with the name ‘Shift Supervisor Group’ already exists.”
Problem is not duplicate name in TF state. State file contains valid ID. Issue appears to be API validation logic rejecting update or re-creation attempts when resource exists but is not linked to current deployment context.
Attempted workaround:
- Delete resource in TF state.
- Run
terraform apply.
Result: Same 400 error. API does not accept creation if name matches existing record, even if original record was deleted via UI or separate API call minutes prior.
Is there a specific header or parameter required for idempotent creation? Or is this a known limitation of the WFM API regarding schedule group names?
Environment details:
- Genesys Cloud: US-East-2
- Terraform: v1.6.0
- Provider: genesys v2.1.0
- CLI: v1.5.4
Need solution for CI/CD pipeline stability. Manual intervention breaks automation flow.