hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.47k stars 4.56k forks source link

Support for Management Group Settings (defaultManagementGroup & requireAuthorizationForGroupCreation) #24234

Open w-kramer opened 7 months ago

w-kramer commented 7 months ago

Is there an existing issue for this?

Community Note

Description

Hello there,

as per Microsoft API Reference, it is possible to configure "defaultManagementGroup" and "requireAuthorizationForGroupCreation". I am missing this in the current azurerm provider. By now, I am using azapi provider to push the configuration, which is quite inconvenient as it doesn't track changes to this setting.

Example for azapi provider:

resource "azapi_resource_action" "management_group_settings" {
  type        = "Microsoft.Management/managementGroups@2021-04-01"
  resource_id = local.tenant_root_group_id
  action      = "settings/default"
  method      = "PATCH"
  body = jsonencode({
    properties = {
      requireAuthorizationForGroupCreation = true
      defaultManagementGroup = var.default_management_group_id
    }
  })
}

New or Affected Resource(s)/Data Source(s)

azurerm_management_group_settings

Potential Terraform Configuration

data "azurerm_management_group" "example" {
  name = "00000000-0000-0000-0000-000000000000"
}

azurerm_management_group_settings "example" {
  defaultManagementGroup = data.azurerm_management_group.example.id
  requireAuthorizationForGroupCreation = true
}

References

https://learn.microsoft.com/en-us/azure/templates/microsoft.management/2021-04-01/managementgroups/settings

rcskosir commented 7 months ago

Thank you for taking the time to open this feature request!