Bylaw

Gallery › Sovereignty › Azure built-in policies

[Preview]: Azure Kubernetes Service clusters should disable public network access

Converted Policy Audit Disabled Mode Indexed Version 1.0.0-preview Preview

Disabling public network access improves security by preventing Azure Kubernetes Service cluster API servers from being accessed over public networks. Ensure that a private access path is configured before disabling public network access.

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

Azure Policy JSONAKS_PublicNetworkAccess_Audit.json · 58 lines
{
  "properties": {
    "displayName": "[Preview]: Azure Kubernetes Service clusters should disable public network access",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disabling public network access improves security by preventing Azure Kubernetes Service cluster API servers from being accessed over public networks. Ensure that a private access path is configured before disabling public network access.",
    "metadata": {
      "version": "1.0.0-preview",
      "category": "Sovereignty",
      "preview": true
    },
    "version": "1.0.0-preview",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.ContainerService/managedClusters"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.ContainerService/managedClusters/publicNetworkAccess",
                "exists": "false"
              },
              {
                "field": "Microsoft.ContainerService/managedClusters/publicNetworkAccess",
                "notEquals": "Disabled"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/f6c2ab23-7f3b-47db-a0dc-24fc64d658fa",
  "name": "f6c2ab23-7f3b-47db-a0dc-24fc64d658fa"
}
Bylawf6c2ab23-7f3b-47db-a0dc-24fc64d658fa.bylaw.ps1 · 33 lines
# Converted from AKS_PublicNetworkAccess_Audit.json by ConvertTo-Bylaw.
Policy 'f6c2ab23-7f3b-47db-a0dc-24fc64d658fa' {

    Properties @{
        DisplayName   = '[Preview]: Azure Kubernetes Service clusters should disable public network access'
        Description   = 'Disabling public network access improves security by preventing Azure Kubernetes Service cluster API servers from being accessed over public networks. Ensure that a private access path is configured before disabling public network access.'
        Version       = '1.0.0-preview'
        Category      = 'Sovereignty'
        Preview       = $true
        PolicyVersion = '1.0.0-preview'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.ContainerService/managedClusters' {

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

        Require 'publicNetworkAccess is Disabled' {
            Field publicNetworkAccess | Must -Be 'Disabled'
        }
    }

    Effect (Param Effect)
}

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