Gallery › Key Vault › Azure Landing Zones Library
KeyVault SoftDelete should be enabled
Converted Policy Append Mode Indexed Version 1.0.0
This policy enables you to ensure when a Key Vault is created with out soft delete enabled it will be added.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONAppend-KV-SoftDelete.alz_policy_definition.json · 48 lines
{
"name": "Append-KV-SoftDelete",
"properties": {
"description": "This policy enables you to ensure when a Key Vault is created with out soft delete enabled it will be added.",
"displayName": "KeyVault SoftDelete should be enabled",
"metadata": {
"alzCloudEnvironments": [
"AzureCloud",
"AzureChinaCloud",
"AzureUSGovernment"
],
"category": "Key Vault",
"source": "https://github.com/Azure/Enterprise-Scale/",
"version": "1.0.0"
},
"mode": "Indexed",
"parameters": {},
"policyRule": {
"if": {
"anyOf": [
{
"allOf": [
{
"equals": "Microsoft.KeyVault/vaults",
"field": "type"
},
{
"field": "Microsoft.KeyVault/vaults/enableSoftDelete",
"notEquals": true
}
]
}
]
},
"then": {
"details": [
{
"field": "Microsoft.KeyVault/vaults/enableSoftDelete",
"value": true
}
],
"effect": "append"
}
},
"policyType": "Custom"
},
"type": "Microsoft.Authorization/policyDefinitions"
}BylawAppend-KV-SoftDelete.bylaw.ps1 · 26 lines
# Converted from Append-KV-SoftDelete.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Append-KV-SoftDelete' {
Properties @{
DisplayName = 'KeyVault SoftDelete should be enabled'
Description = 'This policy enables you to ensure when a Key Vault is created with out soft delete enabled it will be added.'
Category = 'Key Vault'
Version = '1.0.0'
Mode = 'Indexed'
Metadata = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/' }
}
Resource * {
Require 'type and enableSoftDelete are as required' {
AnyOf {
Field type | Must -Not -Be 'Microsoft.KeyVault/vaults' -IfPresent
Field 'Microsoft.KeyVault/vaults/enableSoftDelete' | Must -Be $true
}
}
}
Append {
Field 'Microsoft.KeyVault/vaults/enableSoftDelete' | Add $true
}
}Source: policy_definitions/Append-KV-SoftDelete.alz_policy_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.
Bylaw