[*]
The [*]
and .*
operators are intended for use with lists only. Because this resource uses for_each
rather than count
, its value in other expressions is a map, not a list.
To make your configuration work you’ll need to decide whether it’s better to return a map of names where the keys are the var.bridge_domains
keys, or to return just a set of ids where the caller then couldn’t determine which name belongs to which of the elements of var.bridge_domains
:
output "bd_name" {
value = {
for k, bd in mso_schema_template_bd.bd : k => bd.name
}
}
OR
output "bd_name" {
value = [
for bd in mso_schema_template_bd.bd : bd.name
]
}
If only unique results are desirable in the second example, the function toset
can be used:
output "bd_name" {
value = toset([
for bd in mso_schema_template_bd.bd : bd.name
])
}
This uses for
expressions, which are the more general counterpart of splat expressions that work with collections of any type and which can produce both sequences and mappings as their result, whereas splat expressions work only with lists.