Adding specific users to the first group created

Hello,

I need to place all users whose department is equal to “Exploitation” in the first group I created.

resource "azuread_group" "Terra-Aad-Group" {
  for_each = { for group in local.membersingroups : group.members_groups => group }

  display_name     = format("%s", lower(each.value.members_groups))
  security_enabled = true
}

resource "azuread_group_member" "Terra-Aad-Member-In-Group" {
  for_each = { for u in azuread_user.Terra-Aad-User-Member : u.mail_nickname => u if u.department == "Exploitation" }

  group_object_id  = element(azuread_group.Terra-Aad-Group, 0)
  #element(azuread_group.Terra-Aad-Group, 0)
  member_object_id = each.value.id
}

  output "id_group" {
  value = [[ for id in azuread_group.Terra-Aad-Group : id.object_id], [for us in azuread_user.Terra-Aad-User-Member : us.object_id]]
}

The problem is at the line “group_object_id”. When I try this, I have this :

│ Error: Error in function call
│
│   on groups.tf line 11, in resource "azuread_group_member" "Terra-Aad-Member-In-Group":
│   11:   group_object_id  = element(azuread_group.Terra-Aad-Group, 0)
│     ├────────────────
│     │ azuread_group.Terra-Aad-Group is object with 6 attributes
│
│ Call to function "element" failed: cannot read elements from object.

Does anyone have an idea ?
Thank you very much.