Terraform plan fails with 'conflicts with existing resource' on Genesys Cloud CX as Code export

Running terraform plan after importing a full org export from Genesys Cloud. It’s blowing up on the routing queues.

Error: Error creating RoutingQueue: 409 Conflict
Details: The routing queue 'Support-Tier1' already exists.

I’ve used the genesyscloud-cx-as-code CLI to export the config with --include-ids to keep the UUIDs intact. The generated HCL looks correct, and I’ve verified the id attributes match the live environment.

I’ve tried:

  • Running terraform import on the specific resource. It says it’s already tracked.
  • Removing the state file entry and re-importing. Same conflict error on plan.
  • Checking for duplicate names in the export JSON. There aren’t any.

The issue seems to be that Terraform sees the resource as “new” because the local state doesn’t match the remote reality, even though the IDs are present in the HCL.

Is there a specific flag for the exporter to handle existing IDs better, or do I need to manually script the terraform import for every queue? The org has 500+ queues, so manual isn’t an option.

The 409 conflict usually happens when Terraform tries to create a resource that already exists in the environment, but the state file doesn’t know about it yet. Since you used --include-ids, the HCL has the UUID, but Terraform still thinks it’s a new resource because it’s not in your local state.

You need to import the existing queues into your Terraform state before running plan. The CLI export is fine, but the state sync is missing. Run this for each queue, or script it if you have many:

terraform import genesyscloud_routing_queue.support_tier_1 "the-actual-uuid-from-your-hcl"

If you have a large org, doing this manually is painful. You can use the genesyscloud-cx-as-code CLI to generate an import script. Run:

genesyscloud-cx-as-code import:generate --data-dir ./export --output-file import.sh

This script will generate the terraform import commands for all resources in your export. Execute it, then run terraform plan. It should show no changes if the HCL matches the live config.

One gotcha: if you modified the HCL after export, Terraform will try to update. Make sure the id in your .tf file matches the live UUID exactly. If the IDs don’t match, Terraform sees a mismatch and tries to create a new one, hence the 409.

Also, check for dependent resources. If a queue has a routing rule or skill group that wasn’t exported or imported correctly, the import might fail. Ensure all related objects are in the same export set.

Here’s a quick check to verify the state after import:

terraform state show genesyscloud_routing_queue.support_tier_1

If the ID matches, you’re good. Run plan again. It should be clean. If you still see conflicts, check if multiple modules are trying to manage the same queue. That causes state drift. Keep your modules isolated by queue name or prefix to avoid overlap.