Bylaw

Gallery › Backup › Azure built-in policies

[Preview]: Azure Backup Extension should be installed in AKS clusters

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0-preview Preview

Ensure protection installation of backup extension in your AKS Clusters to leverage Azure Backup. Azure Backup for AKS is a secure and cloud native data protection solution for AKS clusters

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONKubernetes_InstallAzureBackupExtension_Audit.json · 57 lines
{
  "properties": {
    "displayName": "[Preview]: Azure Backup Extension should be installed in AKS clusters",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Ensure protection installation of backup extension in your AKS Clusters to leverage Azure Backup. Azure Backup for AKS is a secure and cloud native data protection solution for AKS clusters",
    "metadata": {
      "version": "1.0.0-preview",
      "category": "Backup",
      "preview": true
    },
    "version": "1.0.0-preview",
    "parameters": {
      "effect": {
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "type": "String",
        "defaultValue": "AuditIfNotExists",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ]
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.ContainerService/managedClusters"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.KubernetesConfiguration/extensions",
          "existenceCondition": {
            "allOf": [
              {
                "field": "Microsoft.KubernetesConfiguration/extensions/extensionType",
                "equals": "microsoft.dataprotection.kubernetes"
              },
              {
                "field": "Microsoft.KubernetesConfiguration/extensions/provisioningState",
                "equals": "Succeeded"
              }
            ]
          }
        }
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/fda9cd0b-094c-4cd5-ac2a-5e06e5277c45",
  "name": "fda9cd0b-094c-4cd5-ac2a-5e06e5277c45"
}
Bylawfda9cd0b-094c-4cd5-ac2a-5e06e5277c45.bylaw.ps1 · 29 lines
# Converted from Kubernetes_InstallAzureBackupExtension_Audit.json by ConvertTo-Bylaw.
Policy 'fda9cd0b-094c-4cd5-ac2a-5e06e5277c45' {

    Properties @{
        DisplayName   = '[Preview]: Azure Backup Extension should be installed in AKS clusters'
        Description   = 'Ensure protection installation of backup extension in your AKS Clusters to leverage Azure Backup. Azure Backup for AKS is a secure and cloud native data protection solution for AKS clusters'
        Version       = '1.0.0-preview'
        Category      = 'Backup'
        Preview       = $true
        PolicyVersion = '1.0.0-preview'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('AuditIfNotExists', 'Disabled')
        Default       = 'AuditIfNotExists'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.ContainerService/managedClusters'

    AuditIfNotExists 'Microsoft.KubernetesConfiguration/extensions' -Effect (Param Effect) {
        Require 'extensionType is microsoft.dataprotection.kubernetes and provisioningState is Succeeded' {
            Field extensionType | Must -Be 'microsoft.dataprotection.kubernetes'
            Field provisioningState | Must -Be 'Succeeded'
        }
    }
}

Source: built-in-policies/policyDefinitions/Backup/Kubernetes_InstallAzureBackupExtension_Audit.json in Azure/azure-policy, under the MIT licence.