Skip to content

Commit 90ed131

Browse files
fix: Add coalesce protection
- Add coalesce instead of merge so as to provide default empty collections so avoiding null-based errors.
1 parent 09e9f48 commit 90ed131

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

locals.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# - Users and Groups -
22
locals {
33
# To support both managed and federated identities, let's combine the two user collections.
4-
sso_users = merge(var.sso_users, var.existing_sso_users)
4+
sso_users = merge(coalesce(var.sso_users, {}), coalesce(var.existing_sso_users, {}))
55

66
# Create a new local variable by flattening the complex type given in the local aggregated variable "sso_users"
77
flatten_user_data = flatten([
8-
for this_user in keys(local.sso_users) : [
9-
for group in local.sso_users[this_user].group_membership : {
10-
user_name = local.sso_users[this_user].user_name
8+
for this_user, user_data in local.sso_users : [
9+
for group in coalesce(user_data.group_membership, []) : {
10+
user_name = user_data.user_name
1111
group_name = group
1212
}
1313
]

0 commit comments

Comments
 (0)