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
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,
]
resource "azurerm_management_group" "customername" {
display_name = var.customerdomainname
subscription_ids = [
#data.azurerm_subscription.current.subscription_id,
]
resource "azurerm_management_group" "company_root" {
name = "company_root"
display_name = "company_root"
}
resource "azurerm_management_group" "sandbox" {
resource "azurerm_management_group" "production" {
display_name = "Production"
id = "Production"
}
resource "azurerm_management_group" "non-production" {
resource "azurerm_management_group" "parent_management_group" {
count = var.deploy_mgmt_groups ? 1 : 0
display_name = var.management_groups.root.name
}
resource "azurerm_management_group" "parent_management_group" {
count = var.deploy_mgmt_groups ? 1 : 0
display_name = var.management_groups.root.name
}
resource "azurerm_management_group" "Root_Management_Group" {
display_name = "Root_Management_Group"
}
#################################################################################################
## CAF Foundation Management Groups ##
resource "azurerm_management_group" "parent_management_group" {
count = var.deploy_mgmt_groups ? 1 : 0
display_name = var.management_groups.root.name
}
resource "azurerm_management_group" "parent_management_group" {
count = var.deploy_mgmt_groups ? 1 : 0
display_name = var.management_groups.root.name
}
resource "azurerm_management_group" "parent_management_group" {
count = var.deploy_mgmt_groups ? 1 : 0
display_name = var.management_groups.root.name
}
Parameters
-
display_name
optional computed - string -
group_id
optional computed - string -
id
optional computed - string -
name
optional computed - string -
parent_management_group_id
optional computed - string -
subscription_ids
optional computed - set of string -
timeouts
single block
Explanation in Terraform Registry
Manages a Management Group. !> Note: Configuring
subscription_ids
is not supported when using theazurerm_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
"type": "Microsoft.Management/managementGroups",
"apiVersion": "2020-05-01",
"name": "[parameters('topLevelManagementGroupPrefix')]",
"properties": {}
},
{
"type": "Microsoft.Management/managementGroups",
"apiVersion": "2020-05-01",
"name": "[parameters('topLevelManagementGroupPrefix')]",
"properties": {}
// },
// {
"type": "Microsoft.Management/managementGroups",
"apiVersion": "2020-05-01",
"name": "[variables('mgName')]",
"properties": {}
},
{
"type": "Microsoft.Management/managementGroups",
"apiVersion": "2020-05-01",
"name": "[parameters('enterpriseScaleCompanyPrefix')]",
"properties": {}
},
{
"type": "Microsoft.Management/managementGroups",
"apiVersion": "2020-05-01",
"name": "[parameters('topLevelManagementGroupPrefix')]",
"properties": {}
},
{
"type": "Microsoft.Management/managementGroups",
"apiVersion": "2020-05-01",
"name": "[parameters('topLevelManagementGroupPrefix')]",
"properties": {}
},
{
"type": "Microsoft.Management/managementGroups",
"apiVersion": "2020-05-01",
"name": "[parameters('topLevelManagementGroupPrefix')]",
"properties": {}
},
{
"type": "Microsoft.Management/managementGroups",
"apiVersion": "2020-05-01",
"name": "[parameters('topLevelManagementGroupPrefix')]",
"properties": {}
},
{
"type": "Microsoft.Management/managementGroups",
"apiVersion": "2020-05-01",
"name": "[parameters('topLevelManagementGroupPrefix')]",
"properties": {}
},
{
"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.