The cycle you’re hitting is a classic state file mess. The genesyscloud provider doesn’t handle circular references well during import because it tries to resolve dependencies in a linear pass. Routing queues need skill groups, which might need users, which might be assigned to other queues. It’s a mess.
You can’t just terraform import everything in one go. You need to break the graph. Start with the leaf nodes-things that don’t depend on anything else. Skills, skill groups, and users first. Then move up to routing queues.
Here’s a safer sequence using terraform import:
# 1. Import Skills (no dependencies)
terraform import genesyscloud_routing_skill.basic 12345678-1234-1234-1234-123456789012
# 2. Import Skill Groups (depend on skills)
terraform import genesyscloud_routing_skill_group.main 22345678-1234-1234-1234-123456789012
# 3. Import Users (depend on skill groups for assignments, but often safe if you skip assignments initially)
terraform import genesyscloud_user.agent 32345678-1234-1234-1234-123456789012
# 4. Import Routing Queues (depend on skill groups and users)
terraform import genesyscloud_routing_queue.main 42345678-1234-1234-1234-123456789012
If you’re using the genesyscloud provider’s export tool, make sure you’re using the --ignore-dependencies flag if available, or manually edit the exported HCL to remove the cyclic references. I usually comment out the member_ids in the skill group until the users are imported.
Also, watch out for the genesyscloud_routing_email_domain resource. It often gets tangled in these cycles if you’re importing email routing rules. Import those last.
The error message you posted cuts off, but it’s likely genesyscloud_routing_queue → genesyscloud_routing_skill_group → genesyscloud_user → genesyscloud_routing_queue. Breaking that loop by importing users without queue assignments first usually fixes it.
You’ll also want to verify the state file after each import batch. Run terraform state list to ensure the IDs are correct. If you see a mismatch, you’ll need to terraform state rm and re-import.
This isn’t pretty, but it works. The provider team is aware of this issue, but for now, manual sequencing is the only reliable way.