I need to locate both AD users and groups without know a priori what sort of data I have.
I can retrieve both types of data, but I can’t see how to unify the two sets of data back together again in the same order that they were provided e.g.
data "azuread_users" {
user_principal_names = var.names
ignore_missing = true
}
data "azuread_groups" {
names = var.names
}
locals {
// TODO: How are we going to unify the two so we get the appropriate object_id for each user/group?
}
This is a bit late but in case it’s useful to anyone:
provider "azuread" {}
data "azuread_domains" "initial" {
only_initial = true
}
data "azuread_users" "example" {
user_principal_names = [
"userName1@${data.azuread_domains.initial.domains[0].domain_name}",
"userName2@${data.azuread_domains.initial.domains[0].domain_name}",
]
}
data "azuread_groups" "example" {
names = ["groupName1", "groupName2"]
}
locals {
user_group_ids = concat(data.azuread_users.example.object_ids, data.azuread_groups.example.object_ids)
}
output "ids" {
value = local.user_group_ids
}