Bylaw

Gallery › Network › Azure Landing Zones Library

Deny vNet peering

Converted Policy Audit Deny Disabled Mode All Version 1.0.1

This policy denies the creation of vNet Peerings under the assigned scope.

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

Azure Policy JSONDeny-VNet-Peering.alz_policy_definition.json · 44 lines
{
  "name": "Deny-VNet-Peering",
  "properties": {
    "description": "This policy denies the creation of vNet Peerings under the assigned scope.",
    "displayName": "Deny vNet peering ",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Network",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.0.1"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny",
        "metadata": {
          "description": "Enable or disable the execution of the policy",
          "displayName": "Effect"
        },
        "type": "String"
      }
    },
    "policyRule": {
      "if": {
        "equals": "Microsoft.Network/virtualNetworks/virtualNetworkPeerings",
        "field": "type"
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawDeny-VNet-Peering.bylaw.ps1 · 23 lines
# Converted from Deny-VNet-Peering.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deny-VNet-Peering' {

    Properties @{
        DisplayName = 'Deny vNet peering '
        Description = 'This policy denies the creation of vNet Peerings under the assigned scope.'
        Category    = 'Network'
        Version     = '1.0.1'
        Mode        = 'All'
        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/virtualNetworks/virtualNetworkPeerings'

    Effect (Param Effect)
}

Source: policy_definitions/Deny-VNet-Peering.alz_policy_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.