Terraform CX as Code: for_each with YAML variable file for queues

Trying to spin up a batch of queues using for_each and a YAML variable file. The docs show JSON examples, but our config is in YAML. When I try to load the YAML into a map for for_each, Terraform complains about the type. Here’s the snippet:

variable "queues" {
 type = map(any)
}

How do I convert the YAML list into a proper map for the loop? Getting Inappropriate value for variable "queues": element "0": number required." errors.

The yamldecode function handles this cleanly. You don’t need complex conversions. Just pass the file content directly.

variable "queues" {
 type = map(any)
}

# In your main.tf or locals
locals {
 queues_map = yamldecode(file("${path.module}/queues.yaml"))
}

Terraform expects a map, not a list. Ensure your YAML structure uses keys, not just a sequence.