Bylaw

Gallery › Kubernetes › Azure built-in policies

Azure Kubernetes Service Clusters should enable Microsoft Entra ID integration

Converted Policy Audit Disabled Mode Indexed Version 1.0.2

AKS-managed Microsoft Entra ID integration can manage the access to the clusters by configuring Kubernetes role-based access control (Kubernetes RBAC) based on a user's identity or directory group membership. Learn more at: https://aka.ms/aks-managed-aad.

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

Azure Policy JSONAKS_AAD_Integration_Audit.json · 50 lines
{
  "properties": {
    "policyType": "BuiltIn",
    "displayName": "Azure Kubernetes Service Clusters should enable Microsoft Entra ID integration",
    "description": "AKS-managed Microsoft Entra ID integration can manage the access to the clusters by configuring Kubernetes role-based access control (Kubernetes RBAC) based on a user's identity or directory group membership. Learn more at: https://aka.ms/aks-managed-aad.",
    "metadata": {
      "version": "1.0.2",
      "category": "Kubernetes"
    },
    "version": "1.0.2",
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "type": "String",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy.",
          "portalReview": true
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.ContainerService/managedClusters"
          },
          {
            "field": "Microsoft.ContainerService/managedClusters/aadProfile",
            "exists": false
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.2"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/450d2877-ebea-41e8-b00c-e286317d21bf",
  "name": "450d2877-ebea-41e8-b00c-e286317d21bf"
}
Bylaw450d2877-ebea-41e8-b00c-e286317d21bf.bylaw.ps1 · 29 lines
# Converted from AKS_AAD_Integration_Audit.json by ConvertTo-Bylaw.
Policy '450d2877-ebea-41e8-b00c-e286317d21bf' {

    Properties @{
        DisplayName   = 'Azure Kubernetes Service Clusters should enable Microsoft Entra ID integration'
        Description   = 'AKS-managed Microsoft Entra ID integration can manage the access to the clusters by configuring Kubernetes role-based access control (Kubernetes RBAC) based on a user''s identity or directory group membership. Learn more at: https://aka.ms/aks-managed-aad.'
        Version       = '1.0.2'
        Category      = 'Kubernetes'
        PolicyVersion = '1.0.2'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy.'
        Metadata      = [ordered]@{ portalReview = $true }
    }

    Resource 'Microsoft.ContainerService/managedClusters' {

        Require 'aadProfile exists' {
            Field aadProfile | Must -Exist
        }
    }

    Effect (Param Effect)
}

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