azurerm_management_group_policy_assignment

Manages a Policy Assignment to a Management Group.

Example Usage

resource "azurerm_management_group" "example" {
  display_name = "Some Management Group"
}

resource "azurerm_policy_definition" "example" {
  name                = "only-deploy-in-westeurope"
  policy_type         = "Custom"
  mode                = "All"
  display_name        = "my-policy-definition"
  management_group_id = azurerm_management_group.example.id

  policy_rule = <<POLICY_RULE
 {
    "if": {
      "not": {
        "field": "location",
        "equals": "westeurope"
      }
    },
    "then": {
      "effect": "Deny"
    }
  }
POLICY_RULE
}

resource "azurerm_management_group_policy_assignment" "example" {
  name                 = "example-policy"
  policy_definition_id = azurerm_policy_definition.example.id
  management_group_id  = azurerm_management_group.example.id
}

Arguments Reference

The following arguments are supported:



A identity block supports the following:


A non_compliance_message block supports the following:


A overrides block supports the following:


A override_selector block supports the following:


A resource_selectors block supports the following:


A resource_selector block supports the following:

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:


The identity block exports the following:

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

Import

Management Group Policy Assignments can be imported using the resource id, e.g.

terraform import azurerm_management_group_policy_assignment.example /providers/Microsoft.Management/managementGroups/group1/providers/Microsoft.Authorization/policyAssignments/assignment1