Gallery › Key Vault › Azure Community Policy
Audit when a given service principal is assigned to the Key Vault data plane
Converted Policy Audit Disabled Mode All Version 1.0.0
Audit when a specified AAD object is granted any permissions to secrets, certs, or keys stored in a Key Vault through data plane access policies.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 53 lines
{
"name": "e614dc30-4489-4e19-86b5-3fd5ae5cfa8b",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Audit when a given service principal is assigned to the Key Vault data plane",
"description": "Audit when a specified AAD object is granted any permissions to secrets, certs, or keys stored in a Key Vault through data plane access policies.",
"metadata": {
"version": "1.0.0",
"category": "Key Vault"
},
"mode": "All",
"parameters": {
"aadObjectId": {
"type": "String",
"metadata": {
"displayName": "AAD Object ID",
"description": "The objectId of the AAD user, group, or service principal to check."
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.KeyVault/vaults"
},
{
"not": {
"field": "Microsoft.Keyvault/vaults/accessPolicies[*].objectId",
"notEquals": "[parameters('aadObjectId')]"
}
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawe614dc30-4489-4e19-86b5-3fd5ae5cfa8b.bylaw.ps1 · 34 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'e614dc30-4489-4e19-86b5-3fd5ae5cfa8b' {
Properties @{
DisplayName = 'Audit when a given service principal is assigned to the Key Vault data plane'
Description = 'Audit when a specified AAD object is granted any permissions to secrets, certs, or keys stored in a Key Vault through data plane access policies.'
Version = '1.0.0'
Category = 'Key Vault'
Mode = 'All'
}
Parameter AadObjectId @{
Type = 'String'
DisplayName = 'AAD Object ID'
Description = 'The objectId of the AAD user, group, or service principal to check.'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.KeyVault/vaults' {
Require 'accessPolicies and objectId are as required' {
Each 'accessPolicies[*]' {
Field objectId | Must -Not -Be (Param AadObjectId)
}
}
}
Effect (Param Effect)
}Source: policyDefinitions/Key Vault/audit-when-a-given-service-principal-is-assigned-to-the-key-vault-data-plane/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw