Bylaw

Gallery › Cache › Azure built-in policies

Azure Cache for Redis Enterprise should use private link

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0

Private endpoints lets you connect your virtual network to Azure services without a public IP address at the source or destination. By mapping private endpoints to your Azure Cache for Redis Enterprise instances, data leakage risks are reduced. Learn more at: https://docs.microsoft.com/azure/azure-cache-for-redis/cache-private-link.

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

Azure Policy JSONRedisCacheEnterprise_PrivateEndpoint_AINE.json · 48 lines
{
  "properties": {
    "displayName": "Azure Cache for Redis Enterprise should use private link",
    "description": "Private endpoints lets you connect your virtual network to Azure services without a public IP address at the source or destination. By mapping private endpoints to your Azure Cache for Redis Enterprise instances, data leakage risks are reduced. Learn more at: https://docs.microsoft.com/azure/azure-cache-for-redis/cache-private-link.",
    "metadata": {
      "version": "1.0.0",
      "category": "Cache"
    },
    "version": "1.0.0",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "defaultValue": "AuditIfNotExists"
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.Cache/redisEnterprise"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Cache/redisEnterprise/privateEndpointConnections",
          "existenceCondition": {
            "field": "Microsoft.Cache/redisEnterprise/privateEndpointConnections/privateLinkServiceConnectionState.status",
            "equals": "Approved"
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/960e650e-9ce3-4316-9590-8ee2c016ca2f",
  "name": "960e650e-9ce3-4316-9590-8ee2c016ca2f"
}
Bylaw960e650e-9ce3-4316-9590-8ee2c016ca2f.bylaw.ps1 · 27 lines
# Converted from RedisCacheEnterprise_PrivateEndpoint_AINE.json by ConvertTo-Bylaw.
Policy '960e650e-9ce3-4316-9590-8ee2c016ca2f' {

    Properties @{
        DisplayName   = 'Azure Cache for Redis Enterprise should use private link'
        Description   = 'Private endpoints lets you connect your virtual network to Azure services without a public IP address at the source or destination. By mapping private endpoints to your Azure Cache for Redis Enterprise instances, data leakage risks are reduced. Learn more at: https://docs.microsoft.com/azure/azure-cache-for-redis/cache-private-link.'
        Version       = '1.0.0'
        Category      = 'Cache'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Cache/redisEnterprise'

    AuditIfNotExists 'Microsoft.Cache/redisEnterprise/privateEndpointConnections' -Effect (Param Effect) {
        Require 'privateLinkServiceConnectionState.status is Approved' {
            Field privateLinkServiceConnectionState.status | Must -Be 'Approved'
        }
    }
}

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