Home > OS >  Add users in azure AD group using terraform by fetching the user details from CSV file
Add users in azure AD group using terraform by fetching the user details from CSV file

Time:11-17

I am following this documents enter image description here

Outputs:

enter image description here

enter image description here

Update for the below error :

enter image description here

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:

enter image description here

enter image description here

enter image description here

  • Related