Bylaw

Gallery › Event Hub › Azure Community Policy

Audit existence of authorization rules on Event Hub entities

Converted Policy AuditIfNotExists Disabled Mode Indexed 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 JSONazurepolicy.json · 39 lines
{
  "name": "72d52002-7cc3-42b9-9aa6-5d39af1e00f1",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Audit existence of authorization rules on Event Hub entities",
    "description": "Audit existence of authorization rules on Event Hub entities to grant least-privileged access",
    "metadata": {
      "category": "Event Hub",
      "version": "1.0.0"
    },
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "AuditIfNotExists or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "defaultValue": "AuditIfNotExists"
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.EventHub/namespaces/eventhubs"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.EventHub/namespaces/eventHubs/authorizationRules"
        }
      }
    }
  }
}
Bylaw72d52002-7cc3-42b9-9aa6-5d39af1e00f1.bylaw.ps1 · 22 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '72d52002-7cc3-42b9-9aa6-5d39af1e00f1' {

    Properties @{
        DisplayName = 'Audit existence of authorization rules on Event Hub entities'
        Description = 'Audit existence of authorization rules on Event Hub entities to grant least-privileged access'
        Category    = 'Event Hub'
        Version     = '1.0.0'
        Mode        = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('AuditIfNotExists', 'Disabled')
        Default       = 'AuditIfNotExists'
        DisplayName   = 'Effect'
        Description   = 'AuditIfNotExists or Disabled the execution of the Policy'
    }

    Resource 'Microsoft.EventHub/namespaces/eventhubs'

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

Source: policyDefinitions/Event Hub/audit-existence-of-authorization-rules-on-event-hub-entities/azurepolicy.json in Azure/Community-Policy, under the MIT licence.