Gallery › Key Vault › Azure built-in policies
Secrets should have the specified maximum validity period
Doesn't convert yet Policy Audit Deny Disabled Mode Microsoft.KeyVault.Data Version 1.0.1
Manage your organizational compliance requirements by specifying the maximum amount of time in days that a secret can be valid within your key vault.
ConvertTo-Bylaw can't convert this policy yet:
- BYL6002 Its mode, Microsoft.KeyVault.Data, is a resource provider mode, which language version 1.0 doesn't support.
Azure Policy JSONSecrets_ValidityPeriod.json · 65 lines
{
"properties": {
"displayName": "Secrets should have the specified maximum validity period",
"policyType": "BuiltIn",
"mode": "Microsoft.KeyVault.Data",
"description": "Manage your organizational compliance requirements by specifying the maximum amount of time in days that a secret can be valid within your key vault.",
"metadata": {
"version": "1.0.1",
"category": "Key Vault"
},
"version": "1.0.1",
"parameters": {
"maximumValidityInDays": {
"type": "Integer",
"metadata": {
"displayName": "The maximum validity period in days",
"description": "Specify the maximum number of days a secret can be valid for. Secrets should be ephemeral. Using a secret with a long validity period is not recommended."
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "'Audit' allows a non-compliant resource to be created, but flags it as non-compliant. 'Deny' blocks the resource creation. 'Disable' turns off the policy."
},
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.KeyVault.Data/vaults/secrets"
},
{
"anyOf": [
{
"field": "Microsoft.KeyVault.Data/vaults/secrets/attributes.expiresOn",
"exists": false
},
{
"field": "Microsoft.KeyVault.Data/vaults/secrets/attributes.expiresOn",
"greater": "[addDays(field('Microsoft.KeyVault.Data/vaults/secrets/attributes.createdOn'), parameters('maximumValidityInDays'))]"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.1"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/342e8053-e12e-4c44-be01-c3c2f318400f",
"name": "342e8053-e12e-4c44-be01-c3c2f318400f"
}Source: built-in-policies/policyDefinitions/Key Vault/Secrets_ValidityPeriod.json in Azure/azure-policy, under the MIT licence.
Bylaw