Terraform for_each with YAML for multiple queues

Trying to use for_each to spin up several queues from a YAML variable file. The yamldecode works fine, but the loop fails. Error says argument must be a map or set. The YAML structure is a list of objects. How do I convert that list into a map for the for_each key? Here is the causing the 400-ish validation error. Any idea on the conversion logic?

Lists don’t work with for_each. You need keys. Try for_each = { for k, v in yamldecode(file("queues.yaml")): k => v }. That turns the list into a map using the index as the key. Then access the queue name via each.value.name. Stops the validation error immediately.