Bylaw

Gallery › Network › Azure Landing Zones Library

Deny the creation of private DNS

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

This policy denies the creation of a private DNS in the current scope, used in combination with policies that create centralized private DNS in connectivity subscription

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

Azure Policy JSONDeny-Private-DNS-Zones.alz_policy_definition.json · 44 lines
{
  "name": "Deny-Private-DNS-Zones",
  "properties": {
    "description": "This policy denies the creation of a private DNS in the current scope, used in combination with policies that create centralized private DNS in connectivity subscription",
    "displayName": "Deny the creation of private DNS",
    "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": {
        "equals": "Microsoft.Network/privateDnsZones",
        "field": "type"
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawDeny-Private-DNS-Zones.bylaw.ps1 · 23 lines
# Converted from Deny-Private-DNS-Zones.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deny-Private-DNS-Zones' {

    Properties @{
        DisplayName = 'Deny the creation of private DNS'
        Description = 'This policy denies the creation of a private DNS in the current scope, used in combination with policies that create centralized private DNS in connectivity subscription'
        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/privateDnsZones'

    Effect (Param Effect)
}

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