I try to get the information from a local variable that contains objects, if at least one of the objects has the attribute "assign" with the value "true" ( assign = true ). My code works, if all of the objects have an attribute "assign" but it fails if any object is missing the attribute.
locals {
assignments = {
users = {
"u1" = {per = ["push"], assign = true}
"u2" = {per = ["push"], assign = false}
}
groups = {
"gr1" = {per = ["o,l"], assign = true}
"gr2" = {per = ["o"]}
"gr3" = {per = ["k"], assign = false}
}
}
}
output "atLeastOneAssign" {
value = anytrue(values(merge(local.assignments.users, local.assignments.groups))[*].assign)
}
So because "gr2" is missing the attribute "assign" the whole thing fails with "This object does not have an attribute named "assign"." I tried it with "try" and "can" but nothing worked. It works like expected, if any object has this attribute but it cannot be guaranteed.
Please help. Thanks in advance.