Bylaw

Gallery › Event Hub › Azure built-in policies

Authorization rules on the Event Hub instance should be defined

Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.0

Audit existence of authorization rules on Event Hub entities to grant least-privileged access

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONAuditEventHubAccessRules_Audit.json · 44 lines
{
  "properties": {
    "displayName": "Authorization rules on the Event Hub instance should be defined",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Audit existence of authorization rules on Event Hub entities to grant least-privileged access",
    "metadata": {
      "version": "1.0.0",
      "category": "Event Hub"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "AuditIfNotExists",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.EventHub/namespaces/eventhubs"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.EventHub/namespaces/eventHubs/authorizationRules"
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/f4826e5f-6a27-407c-ae3e-9582eb39891d",
  "name": "f4826e5f-6a27-407c-ae3e-9582eb39891d"
}
Bylawf4826e5f-6a27-407c-ae3e-9582eb39891d.bylaw.ps1 · 24 lines
# Converted from AuditEventHubAccessRules_Audit.json by ConvertTo-Bylaw.
Policy 'f4826e5f-6a27-407c-ae3e-9582eb39891d' {

    Properties @{
        DisplayName   = 'Authorization rules on the Event Hub instance should be defined'
        Description   = 'Audit existence of authorization rules on Event Hub entities to grant least-privileged access'
        Version       = '1.0.0'
        Category      = 'Event Hub'
        PolicyVersion = '1.0.0'
        Mode          = 'All'
    }

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

    Resource 'Microsoft.EventHub/namespaces/eventhubs'

    AuditIfNotExists 'Microsoft.EventHub/namespaces/eventHubs/authorizationRules' -Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Event Hub/AuditEventHubAccessRules_Audit.json in Azure/azure-policy, under the MIT licence.