Created
August 17, 2020 06:28
-
-
Save anderseide/5be1c9f0d7626c86917796df245dd71e to your computer and use it in GitHub Desktop.
mg-deploy-soft-delete-and-purge-protection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": {}, | |
"functions": [], | |
"variables": {}, | |
"resources": [ | |
{ | |
"name": "deploy-soft-delete-and-purge-protection", | |
"type": "Microsoft.Authorization/policyDefinitions", | |
"apiVersion": "2019-06-01", | |
"properties": { | |
"mode": "All", | |
"displayName": "Enable soft-delete and purge protection on Key Vaults", | |
"description": "This Policy will enable soft-delete and purge protection on all Key Vaults.", | |
"metadata": { | |
"category": "Key Vault" | |
}, | |
"policyRule": { | |
"if": { | |
"allOf": [ | |
{ | |
"field": "type", | |
"equals": "Microsoft.KeyVault/vaults" | |
}, | |
{ | |
"anyOf": [ | |
{ | |
"field": "Microsoft.KeyVault/vaults/enableSoftDelete", | |
"exists": "false" | |
}, | |
{ | |
"field": "Microsoft.KeyVault/vaults/enablePurgeProtection", | |
"exists": "false" | |
} | |
] | |
} | |
] | |
}, | |
"then": { | |
"effect": "DeployIfNotExists", | |
"details": { | |
"type": "Microsoft.KeyVault/vaults", | |
"roleDefinitionIds": [ | |
"/providers/Microsoft.Authorization/roleDefinitions/f25e0fa2-a7c8-4377-a976-54943a77a395" | |
], | |
"existenceCondition": { | |
"allOf": [ | |
{ | |
"field": "Microsoft.KeyVault/vaults/enablePurgeProtection", | |
"equals": "true" | |
}, | |
{ | |
"field": "Microsoft.KeyVault/vaults/enableSoftDelete", | |
"equals": "true" | |
} | |
] | |
}, | |
"deployment": { | |
"properties": { | |
"mode": "incremental", | |
"template": { | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"keyvaultName": { | |
"type": "string" | |
}, | |
"location": { | |
"type": "string" | |
}, | |
"sku": { | |
"type": "object" | |
}, | |
"tenantId": { | |
"type": "string" | |
}, | |
"accessPolicies": { | |
"type": "array" | |
} | |
}, | |
"resources": [ | |
{ | |
"type": "Microsoft.KeyVault/vaults", | |
"apiVersion": "2018-02-14", | |
"name": "[[parameters('keyVaultName')]", | |
"location": "[[parameters('location')]", | |
"properties": { | |
"tenantId": "[[parameters('tenantId')]", | |
"enableSoftDelete": true, | |
"enablePurgeProtection": true, | |
"sku": "[[parameters('sku')]", | |
"accessPolicies": "[[parameters('accessPolicies')]" | |
} | |
} | |
] | |
}, | |
"parameters": { | |
"keyvaultName": { | |
"value": "[[field('name')]" | |
}, | |
"location": { | |
"value": "[[field('location')]" | |
}, | |
"sku": { | |
"value": "[[field('Microsoft.KeyVault/vaults/sku')]" | |
}, | |
"tenantId": { | |
"value": "[[field('Microsoft.KeyVault/vaults/tenantId')]" | |
}, | |
"accessPolicies": { | |
"value": "[[field('Microsoft.KeyVault/vaults/accessPolicies')]" | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"parameters": {} | |
} | |
} | |
], | |
"outputs": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment