Bylaw

Gallery › Event Hub › Azure Community Policy

Event Hub namespaces should have the specified minimum TLS version

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Configure a minimum TLS version for secure communication between the client application and the Event Hub Namespace. To minimize security risk, the recommended minimum TLS version is the latest released version, which is currently TLS 1.2.

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

Azure Policy JSONazurepolicy.json · 68 lines
{
  "name": "4b282e56-3249-4812-8ab8-6e0f208cea7b",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Event Hub namespaces should have the specified minimum TLS version",
    "description": "Configure a minimum TLS version for secure communication between the client application and the Event Hub Namespace. To minimize security risk, the recommended minimum TLS version is the latest released version, which is currently TLS 1.2.",
    "metadata": {
      "category": "Event Hub",
      "version": "1.0.0",
      "preview": false,
      "depreciated": false
    },
    "mode": "Indexed",
    "parameters": {
      "minimumTlsVersion": {
        "type": "String",
        "metadata": {
          "displayName": "Minimum TLS Version",
          "description": "Minimum version of TLS required to access data in the Event Hub Namespace"
        },
        "allowedValues": [
          "1.0",
          "1.1",
          "1.2"
        ],
        "defaultValue": "1.2"
      },
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Deny, Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Deny",
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.EventHub/namespaces"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.EventHub/namespaces/minimumTlsVersion",
                "notEquals": "[parameters('minimumTlsVersion')]"
              },
              {
                "field": "Microsoft.EventHub/namespaces/minimumTlsVersion",
                "exists": "false"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw4b282e56-3249-4812-8ab8-6e0f208cea7b.bylaw.ps1 · 39 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '4b282e56-3249-4812-8ab8-6e0f208cea7b' {

    Properties @{
        DisplayName = 'Event Hub namespaces should have the specified minimum TLS version'
        Description = 'Configure a minimum TLS version for secure communication between the client application and the Event Hub Namespace. To minimize security risk, the recommended minimum TLS version is the latest released version, which is currently TLS 1.2.'
        Category    = 'Event Hub'
        Version     = '1.0.0'
        Preview     = $false
        Mode        = 'Indexed'
        Metadata    = [ordered]@{ depreciated = $false }
    }

    Parameter MinimumTlsVersion @{
        AllowedValues = @('1.0', '1.1', '1.2')
        Default       = '1.2'
        DisplayName   = 'Minimum TLS Version'
        Description   = 'Minimum version of TLS required to access data in the Event Hub Namespace'
    }
    Parameter Effect @{
        AllowedValues = @('Deny', 'Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Deny, Audit or Disabled the execution of the Policy'
    }

    Resource 'Microsoft.EventHub/namespaces' {

        Require 'minimumTlsVersion is the MinimumTlsVersion parameter' {
            Field minimumTlsVersion | Must -Be (Param MinimumTlsVersion)
        }

        Require 'minimumTlsVersion exists' {
            Field minimumTlsVersion | Must -Exist
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Event Hub/event-hub-namespaces-should-have-the-specified-minimum-tls-version/azurepolicy.json in Azure/Community-Policy, under the MIT licence.