Bylaw

Gallery › Cache › Azure Landing Zones Library

Azure Cache for Redis Append a specific min TLS version requirement and enforce TLS.

Converted Policy Append Disabled Mode Indexed Version 1.1.0

Append a specific min TLS version requirement and enforce SSL on Azure Cache for Redis. Enables secure server to client by enforce minimal Tls Version to secure the connection between your database server and your client applications helps protect against 'man in the middle' attacks by encrypting the data stream between the server and your application. This configuration enforces that SSL is always enabled for accessing your database server.

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

Azure Policy JSONAppend-Redis-sslEnforcement.alz_policy_definition.json · 74 lines
{
  "name": "Append-Redis-sslEnforcement",
  "properties": {
    "description": "Append a specific min TLS version requirement and enforce SSL on Azure Cache for Redis. Enables secure server to client by enforce  minimal Tls Version to secure the connection between your database server and your client applications helps protect against 'man in the middle' attacks by encrypting the data stream between the server and your application. This configuration enforces that SSL is always enabled for accessing your database server.",
    "displayName": "Azure Cache for Redis Append a specific min TLS version requirement and enforce TLS.",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Cache",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.1.0"
    },
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "allowedValues": [
          "Append",
          "Disabled"
        ],
        "defaultValue": "Append",
        "metadata": {
          "description": "Enable or disable the execution of the policy minimum TLS version Azure Cache for Redis",
          "displayName": "Effect Azure Cache for Redis"
        },
        "type": "String"
      },
      "minimumTlsVersion": {
        "allowedValues": [
          "1.2",
          "1.1",
          "1.0"
        ],
        "defaultValue": "1.2",
        "metadata": {
          "description": "Select version minimum TLS version Azure Cache for Redis to enforce",
          "displayName": "Select version for Redis server"
        },
        "type": "String"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.Cache/redis",
            "field": "type"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Cache/Redis/minimumTlsVersion",
                "less": "[parameters('minimumTlsVersion')]"
              }
            ]
          }
        ]
      },
      "then": {
        "details": [
          {
            "field": "Microsoft.Cache/Redis/minimumTlsVersion",
            "value": "[parameters('minimumTlsVersion')]"
          }
        ],
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawAppend-Redis-sslEnforcement.bylaw.ps1 · 36 lines
# Converted from Append-Redis-sslEnforcement.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Append-Redis-sslEnforcement' {

    Properties @{
        DisplayName = 'Azure Cache for Redis Append a specific min TLS version requirement and enforce TLS.'
        Description = 'Append a specific min TLS version requirement and enforce SSL on Azure Cache for Redis. Enables secure server to client by enforce  minimal Tls Version to secure the connection between your database server and your client applications helps protect against ''man in the middle'' attacks by encrypting the data stream between the server and your application. This configuration enforces that SSL is always enabled for accessing your database server.'
        Category    = 'Cache'
        Version     = '1.1.0'
        Mode        = 'Indexed'
        Metadata    = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/' }
    }

    Parameter Effect @{
        AllowedValues = @('Append', 'Disabled')
        Default       = 'Append'
        DisplayName   = 'Effect Azure Cache for Redis'
        Description   = 'Enable or disable the execution of the policy minimum TLS version Azure Cache for Redis'
    }
    Parameter MinimumTlsVersion @{
        AllowedValues = @('1.2', '1.1', '1.0')
        Default       = '1.2'
        DisplayName   = 'Select version for Redis server'
        Description   = 'Select version minimum TLS version Azure Cache for Redis to enforce'
    }

    Resource 'Microsoft.Cache/redis' {

        Require 'minimumTlsVersion is at least the MinimumTlsVersion parameter' {
            Field minimumTlsVersion | Must -BeGreaterOrEqual (Param MinimumTlsVersion) -IfPresent
        }
    }

    Append -Effect (Param Effect) {
        Field minimumTlsVersion | Add (Param MinimumTlsVersion)
    }
}

Source: policy_definitions/Append-Redis-sslEnforcement.alz_policy_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.