Azure Management Group

This page shows how to write Terraform and Azure Resource Manager for Management Group and write them securely.

azurerm_management_group (Terraform)

The Group in Management can be configured in Terraform with the resource name azurerm_management_group. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

managementgroups.tf#L6
resource "azurerm_management_group" "managementgroup_parent" {
  display_name = var.managementgroup
/* If you wish to use Subscription ID Mapping with Management Groups
  subscription_ids = [
    data.azurerm_subscription.current.subscription_id,
  ]
main.tf#L4
resource "azurerm_management_group" "customername" {
  display_name = var.customerdomainname

  subscription_ids = [
    #data.azurerm_subscription.current.subscription_id,
  ]
management_groups.tf#L1
resource "azurerm_management_group" "company_root" {
  name = "company_root"
  display_name = "company_root"
}

resource "azurerm_management_group" "sandbox" {
managementGroups.tf#L1
resource "azurerm_management_group" "production" {
  display_name = "Production"
  id           = "Production"
}

resource "azurerm_management_group" "non-production" {
module.tf#L1
resource "azurerm_management_group" "parent_management_group" {
  count = var.deploy_mgmt_groups ? 1 : 0

  display_name = var.management_groups.root.name
}

module.tf#L1
resource "azurerm_management_group" "parent_management_group" {
  count = var.deploy_mgmt_groups ? 1 : 0

    display_name      = var.management_groups.root.name
}

managementGroups.tf#L1
resource "azurerm_management_group" "Root_Management_Group" {
  display_name = "Root_Management_Group"
}

#################################################################################################
##                            CAF Foundation Management Groups                                 ##
module.tf#L1
resource "azurerm_management_group" "parent_management_group" {
  count = var.deploy_mgmt_groups ? 1 : 0

    display_name      = var.management_groups.root.name
}

module.tf#L1
resource "azurerm_management_group" "parent_management_group" {
  count = var.deploy_mgmt_groups ? 1 : 0

    display_name      = var.management_groups.root.name
}

module.tf#L1
resource "azurerm_management_group" "parent_management_group" {
  count = var.deploy_mgmt_groups ? 1 : 0

    display_name      = var.management_groups.root.name
}

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages a Management Group. !> Note: Configuring subscription_ids is not supported when using the azurerm_management_group_subscription_association resource, results will be unpredictable.

Microsoft.Management/managementGroups (Azure Resource Manager)

The managementGroups in Microsoft.Management can be configured in Azure Resource Manager with the resource name Microsoft.Management/managementGroups. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

mgmtGroups.json#L41
            "type": "Microsoft.Management/managementGroups",
            "apiVersion": "2020-05-01",
            "name": "[parameters('topLevelManagementGroupPrefix')]",
            "properties": {}
        },
        {
mgmtGroups.json#L41
            "type": "Microsoft.Management/managementGroups",
            "apiVersion": "2020-05-01",
            "name": "[parameters('topLevelManagementGroupPrefix')]",
            "properties": {}
            // },
            // {
eslzArm.json#L21
            "type": "Microsoft.Management/managementGroups",
            "apiVersion": "2020-05-01",
            "name": "[variables('mgName')]",
            "properties": {}
        },
        {
es-vwan.json#L176
            "type": "Microsoft.Management/managementGroups",
            "apiVersion": "2020-05-01",
            "name": "[parameters('enterpriseScaleCompanyPrefix')]",
            "properties": {}
        },
        {
mgmtGroups.json#L41
            "type": "Microsoft.Management/managementGroups",
            "apiVersion": "2020-05-01",
            "name": "[parameters('topLevelManagementGroupPrefix')]",
            "properties": {}
        },
        {
mgmtGroups.json#L44
            "type": "Microsoft.Management/managementGroups",
            "apiVersion": "2020-05-01",
            "name": "[parameters('topLevelManagementGroupPrefix')]",
            "properties": {}
        },
        {
mgmtGroups.json#L44
            "type": "Microsoft.Management/managementGroups",
            "apiVersion": "2020-05-01",
            "name": "[parameters('topLevelManagementGroupPrefix')]",
            "properties": {}
        },
        {
mgmtGroups.json#L41
            "type": "Microsoft.Management/managementGroups",
            "apiVersion": "2020-05-01",
            "name": "[parameters('topLevelManagementGroupPrefix')]",
            "properties": {}
        },
        {
mgmtGroups.json#L44
            "type": "Microsoft.Management/managementGroups",
            "apiVersion": "2020-05-01",
            "name": "[parameters('topLevelManagementGroupPrefix')]",
            "properties": {}
        },
        {
mgmtGroups.json#L44
            "type": "Microsoft.Management/managementGroups",
            "apiVersion": "2020-05-01",
            "name": "[parameters('topLevelManagementGroupPrefix')]",
            "properties": {}
        },
        {

Frequently asked questions

What is Azure Management Group?

Azure Management Group is a resource for Management of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Management Group?

For Terraform, the azure365pro/AzureManagementGroups, barryhiggins3/terraformhack and mabesignal/azure_examples source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the git-yrh-bloom/arm-bloom-es, geekyninja101/lz-poc-main and ZJQZ/cmp-core-public source code examples are useful. See the Azure Resource Manager Example section for further details.