azure policy to check managedby property of resource group

Dharmaraj 0 Reputation points
2024-05-06T10:44:22.3766667+00:00

hi,

i m trying to create azure policy to make sure the mangedby property is set when creating resources group using terraform.

{ "field": "type", "equals": "Microsoft.Resources/resourceGroups/managedBy" }

but this property does not have an alias to use it in policy.

is there any way i can make this policy work

Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
811 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Theophilus Sawyerr 0 Reputation points
    2024-05-06T14:24:00.9866667+00:00
    {
      "properties": {
        "displayName": "Enforce managedBy property for resource groups",
        "policyType": "Custom",
        "mode": "All",
        "parameters": {},
        "policyRule": {
          "if": {
            "field": "type",
            "equals": "Microsoft.Resources/resourceGroups"
          },
          "then": {
            "effect": "audit",
            "details": {
              "type": "Microsoft.Resources/resourceGroups/managedBy"
            }
          }
        }
      }
    }
    
    
    0 comments No comments