Bylaw

Gallery › Network › Azure Landing Zones Library

Application Gateway should be deployed with WAF enabled

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

This policy enables you to restrict that Application Gateways is always deployed with WAF enabled

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

Azure Policy JSONDeny-AppGW-Without-WAF.alz_policy_definition.json · 52 lines
{
  "name": "Deny-AppGW-Without-WAF",
  "properties": {
    "description": "This policy enables you to restrict that Application Gateways is always deployed with WAF enabled",
    "displayName": "Application Gateway should be deployed with WAF enabled",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Network",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.0.0"
    },
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny",
        "metadata": {
          "description": "Enable or disable the execution of the policy",
          "displayName": "Effect"
        },
        "type": "String"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.Network/applicationGateways",
            "field": "type"
          },
          {
            "field": "Microsoft.Network/applicationGateways/sku.name",
            "notequals": "WAF_v2"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawDeny-AppGW-Without-WAF.bylaw.ps1 · 28 lines
# Converted from Deny-AppGW-Without-WAF.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deny-AppGW-Without-WAF' {

    Properties @{
        DisplayName = 'Application Gateway should be deployed with WAF enabled'
        Description = 'This policy enables you to restrict that Application Gateways is always deployed with WAF enabled'
        Category    = 'Network'
        Version     = '1.0.0'
        Mode        = 'Indexed'
        Metadata    = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/' }
    }

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

    Resource 'Microsoft.Network/applicationGateways' {

        Require 'sku.name is WAF_v2' {
            Field sku.name | Must -Be 'WAF_v2'
        }
    }

    Effect (Param Effect)
}

Source: policy_definitions/Deny-AppGW-Without-WAF.alz_policy_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.