hashicorp / terraform-provider-azuread

Terraform provider for Azure Active Directory
https://registry.terraform.io/providers/hashicorp/azuread/latest/docs
Mozilla Public License 2.0
415 stars 280 forks source link

Documentation: access rights for azuread_group and administrative units. #1420

Open ghjklw opened 1 week ago

ghjklw commented 1 week ago

Community Note

Terraform (and AzureAD Provider) Version

2.53.0

Affected Resource(s)

Terraform Configuration Files

resource "azuread_group" "example" {
  display_name            = "example"
  administrative_unit_ids = [ var.administrative_unit_id ]
  security_enabled        = true
}

Output

β”‚ Error: Creating group in administrative unit with ID "xxxxx", "example"
β”‚ 
β”‚   with azuread_group.example,
β”‚   on main.tf line 2, in resource "azuread_group" "example":
β”‚   2: resource "azuread_group" "example" {
β”‚ 
β”‚ AdministrativeUnitsClient.BaseClient.Post(): unexpected status 403 with
β”‚ OData error: Authorization_RequestDenied: Insufficient privileges to
β”‚ complete the operation.

Expected Behavior

This is not an unexpected behaviour but a permission issue: to create a group within an administrative, the API permission Group.ReadWrite.All is not sufficient: AdministrativeUnit.Read.All is also required. Likewise Groups Administrator role is not sufficient.

In addition, I find the following wording slightly confusing:

When authenticated with a service principal, this resource requires one of the following application roles: Group.ReadWrite.All or Directory.ReadWrite.All.` [...] When authenticated with a user principal, this resource requires one of the following directory roles: Groups Administrator, User Administrator or Global Administrator

Combined with the lack of documentation for the AdministrativeUnit.Read.All requirement, this wording gave me the false impressions that directory roles could only be used with user principals and only API permissions could be used with service principals.

Actual Behavior

I think a slight rewording of the documentation would be helpful. Maybe extending the paragraph dedicated to the case where one want to create a group within an administrative unit, clarifying: