{
  "properties": {
    "displayName": "Certificates 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 that a certificate can be valid within your key vault.",
    "metadata": {
      "version": "2.1.0-preview",
      "category": "Key Vault",
      "preview": true
    },
    "parameters": {
      "maximumValidityInMonths": {
        "type": "Integer",
        "metadata": {
          "displayName": "The maximum validity in months",
          "description": "The limit to how long a certificate may be valid for. Certificates with lengthy validity periods aren't best practice."
        },
      "defaultValue": 12
      },
      "effect": {
        "type": "string",
        "defaultValue": "audit",
        "allowedValues": [
          "audit",
          "deny",
          "disabled"
        ],
        "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."
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.KeyVault.Data/vaults/certificates"
          },
          {
            "field": "Microsoft.KeyVault.Data/vaults/certificates/properties.validityInMonths",
            "greater": "[parameters('maximumValidityInMonths')]"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/0a075868-4c26-42ef-914c-5bc007359560",
  "name": "0a075868-4c26-42ef-914c-5bc007359560"
}