Bylaw

Gallery › Network › Azure Community Policy

Deny load balancer outbound rules

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

This policy deny load balancer outbound rules.

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

Azure Policy JSONazurepolicy.json · 50 lines
{
  "name": "28a98411-2e61-4d5b-a4c2-75547e9f7f12",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Deny load balancer outbound rules",
    "description": "This policy deny load balancer outbound rules.",
    "metadata": {
      "category": "Network",
      "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.Network/loadBalancers",
            "field": "type"
          },
          {
            "count": {
              "field": "Microsoft.Network/loadBalancers/outboundRules[*]"
            },
            "greater": 0
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw28a98411-2e61-4d5b-a4c2-75547e9f7f12.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '28a98411-2e61-4d5b-a4c2-75547e9f7f12' {

    Properties @{
        DisplayName = 'Deny load balancer outbound rules'
        Description = 'This policy deny load balancer outbound rules.'
        Category    = 'Network'
        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.Network/loadBalancers' {

        Require 'outboundRules is as required' {
            Count 'outboundRules[*]' | Must -Be 0
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Network/deny-load-balancer-outbound-rules/azurepolicy.json in Azure/Community-Policy, under the MIT licence.