Gallery › Sovereignty › Azure built-in policies
[Preview]: Azure Key Vault Managed HSM extended regions should use allowed locations
Converted Policy Audit Disabled Mode Indexed Version 1.0.0-preview Preview
Audit Azure Key Vault Managed HSM pools when a multi-region replication extended (secondary) region is outside the list of allowed locations. This policy does not evaluate the pool's primary region.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONManagedHsmReplicaLocations_Audit.json · 72 lines
{
"properties": {
"displayName": "[Preview]: Azure Key Vault Managed HSM extended regions should use allowed locations",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Audit Azure Key Vault Managed HSM pools when a multi-region replication extended (secondary) region is outside the list of allowed locations. This policy does not evaluate the pool's primary region.",
"metadata": {
"version": "1.0.0-preview",
"category": "Sovereignty",
"preview": true
},
"version": "1.0.0-preview",
"parameters": {
"allowedReplicaLocations": {
"type": "Array",
"metadata": {
"displayName": "Allowed extended region locations",
"description": "The list of locations where Azure Key Vault Managed HSM extended (secondary) regions are allowed.",
"strongType": "location"
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.KeyVault/managedHSMs"
},
{
"count": {
"field": "Microsoft.KeyVault/managedHSMs/regions[*]",
"where": {
"allOf": [
{
"field": "Microsoft.KeyVault/managedHSMs/regions[*].isPrimary",
"equals": false
},
{
"value": "[replace(toLower(current('Microsoft.KeyVault/managedHSMs/regions[*].name')), ' ', '')]",
"notIn": "[parameters('allowedReplicaLocations')]"
}
]
}
},
"greater": 0
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.0-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/0eb02880-8961-46b2-a106-107bb2058f00",
"name": "0eb02880-8961-46b2-a106-107bb2058f00"
}Bylaw0eb02880-8961-46b2-a106-107bb2058f00.bylaw.ps1 · 38 lines
# Converted from ManagedHsmReplicaLocations_Audit.json by ConvertTo-Bylaw.
Policy '0eb02880-8961-46b2-a106-107bb2058f00' {
Properties @{
DisplayName = '[Preview]: Azure Key Vault Managed HSM extended regions should use allowed locations'
Description = 'Audit Azure Key Vault Managed HSM pools when a multi-region replication extended (secondary) region is outside the list of allowed locations. This policy does not evaluate the pool''s primary region.'
Version = '1.0.0-preview'
Category = 'Sovereignty'
Preview = $true
PolicyVersion = '1.0.0-preview'
Mode = 'Indexed'
}
Parameter AllowedReplicaLocations @{
Type = 'Array'
DisplayName = 'Allowed extended region locations'
Description = 'The list of locations where Azure Key Vault Managed HSM extended (secondary) regions are allowed.'
Metadata = [ordered]@{ strongType = 'location' }
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.KeyVault/managedHSMs' {
Require 'regions and isPrimary are as required' {
Count 'regions[*]' -Where {
Field isPrimary | Must -Be $false
Arm '[replace(toLower(current(''Microsoft.KeyVault/managedHSMs/regions[*].name'')), '' '', '''')]' | Must -Not -BeIn (Param AllowedReplicaLocations)
} | Must -Be 0
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Sovereignty/ManagedHsmReplicaLocations_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw