Gallery › Resilience › Azure built-in policies
[Preview]: Container Instances should be Zone Aligned
Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0-preview Preview
Container Instances can be configured to be Zone Aligned or not. They are considered Zone Aligned if they have only one entry in their zones array. This policy ensures that they are configured to operate within a single availability zone.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONContainerInstance_containerGroups_ZoneAligned_Audit.json · 55 lines
{
"properties": {
"displayName": "[Preview]: Container Instances should be Zone Aligned",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Container Instances can be configured to be Zone Aligned or not. They are considered Zone Aligned if they have only one entry in their zones array. This policy ensures that they are configured to operate within a single availability zone.",
"metadata": {
"category": "Resilience",
"version": "1.0.0-preview",
"preview": true
},
"version": "1.0.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.ContainerInstance/containerGroups"
},
{
"not": {
"count": {
"field": "Microsoft.ContainerInstance/containerGroups/zones[*]"
},
"equals": 1
}
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.0-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/f58e8c0a-3c79-431a-abf8-cd1b895478e8",
"name": "f58e8c0a-3c79-431a-abf8-cd1b895478e8"
}Bylawf58e8c0a-3c79-431a-abf8-cd1b895478e8.bylaw.ps1 · 29 lines
# Converted from ContainerInstance_containerGroups_ZoneAligned_Audit.json by ConvertTo-Bylaw.
Policy 'f58e8c0a-3c79-431a-abf8-cd1b895478e8' {
Properties @{
DisplayName = '[Preview]: Container Instances should be Zone Aligned'
Description = 'Container Instances can be configured to be Zone Aligned or not. They are considered Zone Aligned if they have only one entry in their zones array. This policy ensures that they are configured to operate within a single availability zone.'
Category = 'Resilience'
Version = '1.0.0-preview'
Preview = $true
PolicyVersion = '1.0.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.ContainerInstance/containerGroups' {
Require 'zones is as required' {
Count 'zones[*]' | Must -Be 1
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Resilience/ContainerInstance_containerGroups_ZoneAligned_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw