last sync: 2021-Sep-22 19:36:51 UTC

Azure Policy definition

Certificates should not expire within the specified number of days

Name Certificates should not expire within the specified number of days
Azure Portal
Id f772fb64-8e40-40ad-87bc-7706e1949427
Version 2.0.1
details on versioning
Category Key Vault
Microsoft docs
Description Manage certificates that will expire within a specified number of days to ensure your organization has sufficient time to rotate the certificate prior to expiration.
Mode Microsoft.KeyVault.Data
Type BuiltIn
Preview FALSE
Deprecated FALSE
Effect Default: audit
Allowed: (audit, deny, disabled)
Used RBAC Role none
History
Date/Time (UTC ymd) (i) Change type Change detail
2021-08-30 14:27:30 change Patch, old suffix: preview (2.0.0-preview > 2.0.1)
2020-09-02 14:03:46 change Previous DisplayName: [Preview]: Manage certificates that are within a specified number of days of expiration
2019-11-19 11:26:09 change Previous DisplayName: [Preview]: Certificates should not expire in the specified number of days
Used in Initiatives none
JSON Changes

JSON
{
  "displayName": "Certificates should not expire within the specified number of days",
  "policyType": "BuiltIn",
  "mode": "Microsoft.KeyVault.Data",
  "description": "Manage certificates that will expire within a specified number of days to ensure your organization has sufficient time to rotate the certificate prior to expiration.",
  "metadata": {
    "version": "2.0.1",
    "category": "Key Vault"
  },
  "parameters": {
    "daysToExpire": {
      "type": "Integer",
      "metadata": {
        "displayName": "Days to expire",
        "description": "The number of days for a certificate to expire."
      }
    },
    "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/certificates"
        },
        {
          "field": "Microsoft.KeyVault.Data/vaults/certificates/attributes.expiresOn",
          "lessOrEquals": "[addDays(utcNow(), parameters('daysToExpire'))]"
        }
      ]
    },
    "then": {
      "effect": "[parameters('effect')]"
    }
  }
}