Bylaw

Gallery › Backup › Azure built-in policies

[Preview]: Azure Backup should be enabled for AKS clusters

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0-preview Preview

Ensure protection of your AKS Clusters by enabling 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_EnableAzureBackup_Audit.json · 45 lines
{
  "properties": {
    "displayName": "[Preview]: Azure Backup should be enabled for AKS clusters",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Ensure protection of your AKS Clusters by enabling 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.DataProtection/backupInstances"
        }
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/0b0434ec-2bad-4229-965f-bb7ae5a71257",
  "name": "0b0434ec-2bad-4229-965f-bb7ae5a71257"
}
Bylaw0b0434ec-2bad-4229-965f-bb7ae5a71257.bylaw.ps1 · 24 lines
# Converted from Kubernetes_EnableAzureBackup_Audit.json by ConvertTo-Bylaw.
Policy '0b0434ec-2bad-4229-965f-bb7ae5a71257' {

    Properties @{
        DisplayName   = '[Preview]: Azure Backup should be enabled for AKS clusters'
        Description   = 'Ensure protection of your AKS Clusters by enabling 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.DataProtection/backupInstances' -Effect (Param Effect)
}

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