Bylaw

Gallery › Key Vault › Azure built-in policies

Certificates should have the specified maximum validity period

Doesn't convert yet Policy Audit Deny Disabled Mode Microsoft.KeyVault.Data Version 2.2.1

Manage your organizational compliance requirements by specifying the maximum amount of time that a certificate can be valid within your key vault.

ConvertTo-Bylaw can't convert this policy yet:

Azure Policy JSONCertificates_ValidityPeriod.json · 62 lines
{
  "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.2.1",
      "category": "Key Vault"
    },
    "version": "2.2.1",
    "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",
        "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",
          "Audit",
          "deny",
          "Deny",
          "disabled",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "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')]"
      }
    },
    "versions": [
      "2.2.1",
      "2.2.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/0a075868-4c26-42ef-914c-5bc007359560",
  "name": "0a075868-4c26-42ef-914c-5bc007359560"
}

Source: built-in-policies/policyDefinitions/Key Vault/Certificates_ValidityPeriod.json in Azure/azure-policy, under the MIT licence.