Need some help troubleshooting
Background
Deploying Genesys Cloud via Terraform. Provider genesyscloud 2.15.0. Region ap-southeast-2.
Issue
genesyscloud_routing_skill_group fails with 409 Conflict. Error: Resource already exists. This happens on clean state import.
Troubleshooting
- Verified no duplicates in UI.
- API GET returns 404 for the ID.
- Retrying apply gives same error.
HCL snippet:
resource "genesyscloud_routing_skill_group" "main" {
name = "Support-SG"
}
Any ideas?
The 409 conflict in the Genesys Cloud Terraform provider often stems from how the provider handles resource existence checks for routing entities. The provider might be querying by name instead of ID, or failing to detect the resource during the import phase if the name contains special characters that get URL-encoded differently.
First, verify the exact name and division ID of the skill group in the Genesys Cloud Admin portal. The name must match exactly, including case sensitivity. If the resource exists in the UI but not in your Terraform state, you need to import it correctly.
Try this import command, ensuring you use the UUID from the URL or API response, not the name:
If the import fails with a similar 409, the provider might be trying to create the resource before verifying its existence. A workaround is to add lifecycle { prevent_destroy = true } to your resource block temporarily, or check if there is a duplicate skill group in a different division.
Also, ensure your Terraform provider version is up to date. Version 2.15.0 had some known issues with routing resource imports. Updating to the latest stable version often resolves these conflicts due to improved existence checks.
If the issue persists, check the Terraform logs for the exact API call being made. You can enable debug logging by setting TF_LOG=DEBUG before running terraform apply. This will show you the request payload and the response from the Genesys Cloud API, helping you identify why the provider thinks the resource already exists.
In my experience with bulk exports and metadata, similar conflicts arise when the system detects a resource with the same name but different attributes. Ensure all attributes in your Terraform config match the existing resource exactly, including any custom metadata or division assignments.
terraform import genesyscloud_routing_skill_group.my_skill_group <skill_group_uuid>
I’d recommend looking at at how Genesys Cloud handles unique identifiers for routing resources compared to the simpler ticket tag systems we relied on in Zendesk. The 409 conflict during Terraform apply often occurs because the provider struggles with name-based lookups when special characters or whitespace are involved, much like how Zendesk API calls fail if tags aren’t URL-encoded perfectly.
The suggestion above hits the nail on the head regarding name matching, but here is a more robust way to handle this during a migration from Zendesk to Genesys Cloud. When mapping Zendesk tags to Genesys Cloud skill groups, ensure the Terraform state file is clean and the resource IDs are explicitly referenced rather than relying solely on names.
Try these steps to resolve the conflict:
- Verify Division ID: Ensure the
division_id in your Terraform config matches the exact division where the skill group resides in Genesys Cloud. A mismatch here causes the provider to think the resource doesn’t exist or conflicts with another.
- Clean State Import: Run
terraform state rm genesyscloud_routing_skill_group.your_skill_group and then use terraform import with the explicit ID from the Genesys Cloud Admin UI, not the name.
- Check Special Characters: If your skill group name contains spaces or hyphens, ensure they are encoded correctly. Genesys Cloud’s API is stricter than Zendesk’s on this front.
- Review Provider Version: Ensure you are using the latest stable version of the
genesyscloud provider, as older versions had known bugs with routing resource conflicts.
This approach mirrors how we handle ticket field mapping in Zendesk - explicit ID references prevent most sync issues. Let me know if this clears up the 409 error!
This is a standard state synchronization issue where the Terraform provider is failing to correctly map the local configuration to the existing Genesys Cloud resource during the import process. When managing multiple BYOC trunks across different regions, we often see similar ID mismatches if the division ID is not explicitly defined in the resource block. The provider defaults to the main division if left unspecified, causing a conflict when it attempts to create a duplicate in the wrong scope. Ensure the division_id matches the specific routing division in your AP-SG environment.
resource "genesyscloud_routing_skill_group" "primary_sg" {
name = "Predictive_Routing_SG"
description = "Primary skill group for predictive campaigns"
division_id = "your-specific-division-id-here"
routing_language {
language_code = "en"
priority = 1
}
}
Verify the division ID in the Admin console under Routing > Skill Groups to prevent these 409 errors.