Bylaw

Gallery › Cache › Azure built-in policies

Only secure connections to your Azure Cache for Redis should be enabled

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Audit enabling of only connections via SSL to Azure Cache for Redis. Use of secure connections ensures authentication between the server and the service and protects data in transit from network layer attacks such as man-in-the-middle, eavesdropping, and session-hijacking

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

Azure Policy JSONRedisCache_AuditSSLPort_Audit.json · 50 lines
{
  "properties": {
    "displayName": "Only secure connections to your Azure Cache for Redis should be enabled",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Audit enabling of only connections via SSL to Azure Cache for Redis. Use of secure connections ensures authentication between the server and the service and protects data in transit from network layer attacks such as man-in-the-middle, eavesdropping, and session-hijacking",
    "metadata": {
      "version": "1.0.0",
      "category": "Cache"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "The effect determines what happens when the policy rule is evaluated to match"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Cache/redis"
          },
          {
            "field": "Microsoft.Cache/Redis/enableNonSslPort",
            "equals": "true"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/22bee202-a82f-4305-9a2a-6d7f44d4dedb",
  "name": "22bee202-a82f-4305-9a2a-6d7f44d4dedb"
}
Bylaw22bee202-a82f-4305-9a2a-6d7f44d4dedb.bylaw.ps1 · 29 lines
# Converted from RedisCache_AuditSSLPort_Audit.json by ConvertTo-Bylaw.
Policy '22bee202-a82f-4305-9a2a-6d7f44d4dedb' {

    Properties @{
        DisplayName   = 'Only secure connections to your Azure Cache for Redis should be enabled'
        Description   = 'Audit enabling of only connections via SSL to Azure Cache for Redis. Use of secure connections ensures authentication between the server and the service and protects data in transit from network layer attacks such as man-in-the-middle, eavesdropping, and session-hijacking'
        Version       = '1.0.0'
        Category      = 'Cache'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }

    Resource 'Microsoft.Cache/redis' {

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

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Cache/RedisCache_AuditSSLPort_Audit.json in Azure/azure-policy, under the MIT licence.