terraform-provider-azuread icon indicating copy to clipboard operation
terraform-provider-azuread copied to clipboard

Add support for "mail" lookup

Open trajano opened this issue 4 years ago • 3 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritise this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritise the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

The following also works so if we had a mail option for the data "azuread_user" this would solve the issue. It should throw an error if it detects that the query will return more than one result.

az ad user list --filter "mail eq '[email protected]'"

New or Affected Resource(s)

  • data azuread_user

Potential Terraform Configuration

data "azuread_user" "YYYY" {
  mail = "[email protected]"
}

References

  • #275

trajano avatar Jun 16 '20 16:06 trajano

Hi @trajano, I'm looking at adding this and have an untested implementation. However, we're currently unable to test this due to the mail field being (a) readonly and (b) only populated for users with an O365 license. I'll look further into this.

manicminer avatar Jul 01 '20 02:07 manicminer

I'm actually just using the Terraform azuread to help manage my Office 365 installation (rather than an Azure system)

trajano avatar Jul 02 '20 05:07 trajano

Our workaround for now

data "azuread_user" "ContractorDevelopers" {
  for_each = merge(
    { for e in csvdecode(file("data/ContractorDevelopers.csv")) : e.Email => "${replace(e.Email, "@", "_")}#EXT#@${var.tenant_domain}" }
  )
  user_principal_name = each.value
}

Where the CSV file contains e-mail addresses only. no other fields.

trajano avatar Mar 15 '21 12:03 trajano

This functionality has been released in v2.37.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

github-actions[bot] avatar Apr 13 '23 22:04 github-actions[bot]