Bylaw

Gallery › Cache › Azure Landing Zones Library

Azure Cache for Redis Append and the enforcement that enableNonSslPort is disabled.

Converted Policy Append Disabled Mode Indexed Version 1.0.1

Azure Cache for Redis Append and the enforcement that enableNonSslPort is disabled. 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-disableNonSslPort.alz_policy_definition.json · 61 lines
{
  "name": "Append-Redis-disableNonSslPort",
  "properties": {
    "description": "Azure Cache for Redis Append and the enforcement that enableNonSslPort is disabled. 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 and the enforcement that enableNonSslPort is disabled.",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Cache",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.0.1"
    },
    "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"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.Cache/redis",
            "field": "type"
          },
          {
            "anyOf": [
              {
                "equals": "true",
                "field": "Microsoft.Cache/Redis/enableNonSslPort"
              }
            ]
          }
        ]
      },
      "then": {
        "details": [
          {
            "field": "Microsoft.Cache/Redis/enableNonSslPort",
            "value": false
          }
        ],
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawAppend-Redis-disableNonSslPort.bylaw.ps1 · 30 lines
# Converted from Append-Redis-disableNonSslPort.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Append-Redis-disableNonSslPort' {

    Properties @{
        DisplayName = 'Azure Cache for Redis Append and the enforcement that enableNonSslPort is disabled.'
        Description = 'Azure Cache for Redis Append and the enforcement that enableNonSslPort is disabled. 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.0.1'
        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'
    }

    Resource 'Microsoft.Cache/redis' {

        Require 'enableNonSslPort is not true' {
            Field enableNonSslPort | Must -Not -Be 'true' -IfPresent
        }
    }

    Append -Effect (Param Effect) {
        Field enableNonSslPort | Add $false
    }
}

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