Gallery › Resilience › Azure built-in policies
[Preview]: Azure Cache for Redis should be Zone Redundant
Converted Policy Audit Deny Disabled Mode Indexed Version 1.1.0-preview Preview
Azure Cache for Redis can be configured to be Zone Redundant or not. Azure Cache for Redis instances with fewer than 2 entries in their zones array or zonalAllocationPolicy is set to 'NoZones' or the sku is 'Basic' are not Zone Redundant. This policy identifies Azure Cache for Redis instances lacking the redundancy needed to withstand a zone outage.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONCache_Redis_ZoneRedundant_Audit.json · 78 lines
{
"properties": {
"displayName": "[Preview]: Azure Cache for Redis should be Zone Redundant",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Azure Cache for Redis can be configured to be Zone Redundant or not. Azure Cache for Redis instances with fewer than 2 entries in their zones array or zonalAllocationPolicy is set to 'NoZones' or the sku is 'Basic' are not Zone Redundant. This policy identifies Azure Cache for Redis instances lacking the redundancy needed to withstand a zone outage.",
"metadata": {
"category": "Resilience",
"version": "1.1.0-preview",
"preview": true
},
"version": "1.1.0-preview",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "This parameter lets you choose the effect of the policy. If you choose Audit (default), the policy will only audit resources for compliance. If you choose Deny, the policy will deny the creation of non-compliant resources. If you choose Disabled, the policy will not enforce compliance (useful, for example, as a second assignment to ignore a subset of non-compliant resources in a single resource group)."
},
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Cache/Redis"
},
{
"anyOf": [
{
"allOf": [
{
"field": "Microsoft.Cache/Redis/zones[*]",
"exists": true
},
{
"count": {
"field": "Microsoft.Cache/Redis/zones[*]"
},
"less": 2
},
{
"field": "Microsoft.Cache/Redis/zonalAllocationPolicy",
"notEquals": "Automatic"
}
]
},
{
"field": "Microsoft.Cache/Redis/zonalAllocationPolicy",
"equals": "NoZones"
},
{
"field": "Microsoft.Cache/Redis/sku.name",
"equals": "Basic"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.1.0-PREVIEW",
"1.0.0-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/1bf67da8-b100-45bf-b89d-e4669fc54411",
"name": "1bf67da8-b100-45bf-b89d-e4669fc54411"
}Bylaw1bf67da8-b100-45bf-b89d-e4669fc54411.bylaw.ps1 · 46 lines
# Converted from Cache_Redis_ZoneRedundant_Audit.json by ConvertTo-Bylaw.
Policy '1bf67da8-b100-45bf-b89d-e4669fc54411' {
Properties @{
DisplayName = '[Preview]: Azure Cache for Redis should be Zone Redundant'
Description = 'Azure Cache for Redis can be configured to be Zone Redundant or not. Azure Cache for Redis instances with fewer than 2 entries in their zones array or zonalAllocationPolicy is set to ''NoZones'' or the sku is ''Basic'' are not Zone Redundant. This policy identifies Azure Cache for Redis instances lacking the redundancy needed to withstand a zone outage.'
Category = 'Resilience'
Version = '1.1.0-preview'
Preview = $true
PolicyVersion = '1.1.0-preview'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Deny', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'This parameter lets you choose the effect of the policy. If you choose Audit (default), the policy will only audit resources for compliance. If you choose Deny, the policy will deny the creation of non-compliant resources. If you choose Disabled, the policy will not enforce compliance (useful, for example, as a second assignment to ignore a subset of non-compliant resources in a single resource group).'
}
Resource 'Microsoft.Cache/Redis' {
Require 'zones and zonalAllocationPolicy are as required' {
AnyOf {
AnyOf {
Field zones | Must -Not -Exist
Count 'zones[*]' -Where {
Element | Must -Not -Exist
} | Must -Not -Be 0
}
Count 'zones[*]' | Must -BeGreaterOrEqual 2
Field zonalAllocationPolicy | Must -Be 'Automatic'
}
}
Require 'zonalAllocationPolicy is not NoZones' {
Field zonalAllocationPolicy | Must -Not -Be 'NoZones' -IfPresent
}
Require 'sku.name is not Basic' {
Field sku.name | Must -Not -Be 'Basic' -IfPresent
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Resilience/Cache_Redis_ZoneRedundant_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw