I have a variable that is a list of objects, similar to
variable "rules" {
type = list(object({
names = list(string)
foo = string
}))
}
I’m using this variable to create multiple resources like so:
resource "foo_resource" "this" {
for_each = { ... }
...
}
What I’d like to do is to be able to transform the following list of objects:
locals {
input = [
{
names = ["a", "b"]
foo = "something"
},
{
names = ["c", "d"]
foo = "something-else"
]
}
into the following map:
locals {
desired_output = {
"a" => { foo => "something" }
"b" => { foo => "something" }
"c" => { foo => "something-else" }
"d" => { foo => "something-else" }
}
}
thoughts on how to accomplish this?