Outputs:
Update for the below error :
If you are using Duplicates then you will have to convert the list to map by doing indexing, so you can use the for the loops like below :
data "azuread_user" "user" {
for_each = { for i , user in local.users : i => user }
user_principal_name = each.value.AzureUserPrincipalName
}
resource "azuread_group" "dev-team" {
display_name = "inx-dev"
security_enabled = true
}
resource "azuread_group_member" "member" {
for_each = { for i,user in local.users : i => user if user.AzureGroup == "api-jnk-cld-ops" }
group_object_id = azuread_group.dev-team.id
member_object_id = data.azuread_user.user[each.key].id
}
Outputs: