Why is this setting causing a parsing error when I try to map YAML keys to Genesys Cloud queues?
Background
I am building a CX as Code pipeline. I need to create multiple queues from a single YAML variable file. I am using the Terraform Provider for Genesys Cloud. I want to use for_each to iterate over the YAML data. My YAML file (queues.yaml) looks like this:
queues:
sales_us:
name: "Sales US"
description: "US Sales Team"
support_eu:
name: "Support EU"
description: "EU Support Team"
Issue
I load the YAML into Terraform using yamldecode(file("queues.yaml")). I then pass this to for_each. However, the genesyscloud_routing_queue resource fails during terraform plan.
locals {
queue_data = yamldecode(file("queues.yaml"))
}
resource "genesyscloud_routing_queue" "example" {
for_each = local.queue_data.queues
name = each.value.name
}
The error message is: Invalid index. An object with no attribute collection is not addressable.
Troubleshooting
- I checked the YAML syntax. It is valid.
- I printed
local.queue_data.queuesand it shows a map of objects. - I tried using
keys()but it does not help with the value access.
How do I correctly structure the for_each loop to handle this nested YAML structure?