Bylaw

Gallery › Event Hub › Azure Landing Zones Library

Event Hub namespaces (Premium) should use a customer-managed key for encryption

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

Event Hub namespaces (Premium) should use a customer-managed key for encryption.

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

Azure Policy JSONDeny-EH-Premium-CMK.alz_policy_definition.json · 58 lines
{
  "name": "Deny-EH-Premium-CMK",
  "properties": {
    "description": "Event Hub namespaces (Premium) should use a customer-managed key for encryption.",
    "displayName": "Event Hub namespaces (Premium) should use a customer-managed key for encryption",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Event Hub",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.0.0"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny",
        "metadata": {
          "description": "Enable or disable the execution of the policy",
          "displayName": "Effect"
        },
        "type": "String"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.EventHub/namespaces",
            "field": "type"
          },
          {
            "equals": "Premium",
            "field": "Microsoft.EventHub/namespaces/sku.name"
          },
          {
            "not": {
              "equals": "Microsoft.Keyvault",
              "field": "Microsoft.EventHub/namespaces/encryption.keySource"
            }
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawDeny-EH-Premium-CMK.bylaw.ps1 · 32 lines
# Converted from Deny-EH-Premium-CMK.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deny-EH-Premium-CMK' {

    Properties @{
        DisplayName = 'Event Hub namespaces (Premium) should use a customer-managed key for encryption'
        Description = 'Event Hub namespaces (Premium) should use a customer-managed key for encryption.'
        Category    = 'Event Hub'
        Version     = '1.0.0'
        Mode        = 'All'
        Metadata    = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/' }
    }

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

    Resource 'Microsoft.EventHub/namespaces' {

        When {
            Field sku.name | Must -Be 'Premium'
        }

        Require 'encryption.keySource is Microsoft.Keyvault' {
            Field encryption.keySource | Must -Be 'Microsoft.Keyvault'
        }
    }

    Effect (Param Effect)
}

Source: policy_definitions/Deny-EH-Premium-CMK.alz_policy_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.