Bylaw

Gallery › Kubernetes › Azure Community Policy

AKS prevent load balancer profile

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

This policy prevent load balancer profile for aks.

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

Azure Policy JSONazurepolicy.json · 48 lines
{
  "name": "c8187ecd-531e-4889-89cc-69835860ebdf",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "AKS prevent load balancer profile",
    "description": "This policy prevent load balancer profile for aks.",
    "metadata": {
      "category": "Kubernetes",
      "createdBy": "",
      "updatedBy": null,
      "updatedOn": null,
      "version": "1.0.0"
    },
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Deny, Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Deny",
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.ContainerService/managedClusters",
            "field": "type"
          },
          {
            "exists": true,
            "field": "Microsoft.ContainerService/managedClusters/networkProfile.loadBalancerProfile"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylawc8187ecd-531e-4889-89cc-69835860ebdf.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'c8187ecd-531e-4889-89cc-69835860ebdf' {

    Properties @{
        DisplayName = 'AKS prevent load balancer profile'
        Description = 'This policy prevent load balancer profile for aks.'
        Category    = 'Kubernetes'
        Version     = '1.0.0'
        Mode        = 'Indexed'
    }

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

    Resource 'Microsoft.ContainerService/managedClusters' {

        Require 'networkProfile.loadBalancerProfile does not exist' {
            Field networkProfile.loadBalancerProfile | Must -Not -Exist
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Kubernetes/aks-prevent-load-balancer-profile/azurepolicy.json in Azure/Community-Policy, under the MIT licence.