Bylaw

Gallery › Lighthouse › Azure built-in policies

Audit delegation of scopes to a managing tenant

Uses Condition Policy Audit Disabled Mode All Version 1.0.0

Audit delegation of scopes to a managing tenant via Azure Lighthouse.

ConvertTo-Bylaw converted this policy, and proved it compiles back to the same definition. Conditions the language can't express yet are written as raw JSON with Condition.

Azure Policy JSONDelegations_Audit.json · 49 lines
{
  "properties": {
    "displayName": "Audit delegation of scopes to a managing tenant",
    "description": "Audit delegation of scopes to a managing tenant via Azure Lighthouse.",
    "policyType": "BuiltIn",
    "mode": "All",
    "metadata": {
      "version": "1.0.0",
      "category": "Lighthouse"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.ManagedServices/registrationAssignments"
          },
          {
            "value": "true",
            "equals": "true"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/76bed37b-484f-430f-a009-fd7592dff818",
  "name": "76bed37b-484f-430f-a009-fd7592dff818"
}
Bylaw76bed37b-484f-430f-a009-fd7592dff818.bylaw.ps1 · 29 lines
# Converted from Delegations_Audit.json by ConvertTo-Bylaw.
Policy '76bed37b-484f-430f-a009-fd7592dff818' {

    Properties @{
        DisplayName   = 'Audit delegation of scopes to a managing tenant'
        Description   = 'Audit delegation of scopes to a managing tenant via Azure Lighthouse.'
        Version       = '1.0.0'
        Category      = 'Lighthouse'
        PolicyVersion = '1.0.0'
        Mode          = 'All'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.ManagedServices/registrationAssignments' {

        Require 'Requirement 1' {
            Condition -Violation '{ "value": "true", "equals": "true" }'
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Lighthouse/Delegations_Audit.json in Azure/azure-policy, under the MIT licence.