Bylaw

Gallery › Network › Azure built-in policies

Network interfaces should not have public IPs

Converted Policy Deny Mode Indexed Version 1.0.0

This policy denies the network interfaces which are configured with any public IP. Public IP addresses allow internet resources to communicate inbound to Azure resources, and Azure resources to communicate outbound to the internet. This should be reviewed by the network security team.

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

Azure Policy JSONNetworkPublicIPNic_Deny.json · 38 lines
{
  "properties": {
    "displayName": "Network interfaces should not have public IPs",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy denies the network interfaces which are configured with any public IP. Public IP addresses allow internet resources to communicate inbound to Azure resources, and Azure resources to communicate outbound to the internet. This should be reviewed by the network security team.",
    "metadata": {
      "version": "1.0.0",
      "category": "Network"
    },
    "version": "1.0.0",
    "parameters": {},
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Network/networkInterfaces"
          },
          {
            "not": {
              "field": "Microsoft.Network/networkInterfaces/ipconfigurations[*].publicIpAddress.id",
              "notLike": "*"
            }
          }
        ]
      },
      "then": {
        "effect": "deny"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/83a86a26-fd1f-447c-b59d-e51f44264114",
  "name": "83a86a26-fd1f-447c-b59d-e51f44264114"
}
Bylaw83a86a26-fd1f-447c-b59d-e51f44264114.bylaw.ps1 · 23 lines
# Converted from NetworkPublicIPNic_Deny.json by ConvertTo-Bylaw.
Policy '83a86a26-fd1f-447c-b59d-e51f44264114' {

    Properties @{
        DisplayName   = 'Network interfaces should not have public IPs'
        Description   = 'This policy denies the network interfaces which are configured with any public IP. Public IP addresses allow internet resources to communicate inbound to Azure resources, and Azure resources to communicate outbound to the internet. This should be reviewed by the network security team.'
        Version       = '1.0.0'
        Category      = 'Network'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

    Resource 'Microsoft.Network/networkInterfaces' {

        Require 'ipconfigurations and publicIpAddress.id are as required' {
            Each 'ipconfigurations[*]' {
                Field publicIpAddress.id | Must -Not -BeLike '*'
            }
        }
    }

    Effect Deny
}

Source: built-in-policies/policyDefinitions/Network/NetworkPublicIPNic_Deny.json in Azure/azure-policy, under the MIT licence.