Trying to generate multiple Genesys Cloud queues from a YAML variable file using for_each. The YAML structure looks like this:
queues:
- name: "Support-EN"
description: "English Support"
out_of_office_enabled: false
- name: "Support-FR"
description: "French Support"
out_of_office_enabled: true
I’m loading this in Terraform with yamldecode(file("vars.yaml")) and iterating over var.queues.queues. The issue is that genesyscloud_routing_queue requires a unique name for each resource, but for_each keys need to be stable strings. Using the queue name as the key works for creation, but if I rename a queue in the YAML, Terraform tries to destroy and recreate it instead of updating. I tried using toset on the names, but then I lose the mapping to the descriptions and other attributes. Is there a clean way to handle this without hardcoding resource blocks? The current setup breaks on any name change.
resource "genesyscloud_routing_queue" "queue" {
for_each = { for q in var.queues.queues : q.name => q }
name = each.value.name
description = each.value.description
out_of_office_enabled = each.value.out_of_office_enabled
}