Bylaw

Gallery › Sovereignty › Azure built-in policies

[Preview]: Azure Container Instances container groups should disable public network access

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0-preview Preview

Disabling public network access on Azure Container Instances container groups improves security by preventing the deployment of public inbound IP endpoints.

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

Azure Policy JSONContainerInstance_PublicNetworkAccess_Audit.json · 51 lines
{
  "properties": {
    "displayName": "[Preview]: Azure Container Instances container groups should disable public network access",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disabling public network access on Azure Container Instances container groups improves security by preventing the deployment of public inbound IP endpoints.",
    "metadata": {
      "version": "1.0.0-preview",
      "category": "Sovereignty",
      "preview": true
    },
    "version": "1.0.0-preview",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.ContainerInstance/containerGroups"
          },
          {
            "field": "Microsoft.ContainerInstance/containerGroups/ipAddress.type",
            "equals": "Public"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/f5727640-3711-4df4-bce5-3ba3ad4bad85",
  "name": "f5727640-3711-4df4-bce5-3ba3ad4bad85"
}
Bylawf5727640-3711-4df4-bce5-3ba3ad4bad85.bylaw.ps1 · 29 lines
# Converted from ContainerInstance_PublicNetworkAccess_Audit.json by ConvertTo-Bylaw.
Policy 'f5727640-3711-4df4-bce5-3ba3ad4bad85' {

    Properties @{
        DisplayName   = '[Preview]: Azure Container Instances container groups should disable public network access'
        Description   = 'Disabling public network access on Azure Container Instances container groups improves security by preventing the deployment of public inbound IP endpoints.'
        Version       = '1.0.0-preview'
        Category      = 'Sovereignty'
        Preview       = $true
        PolicyVersion = '1.0.0-preview'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.ContainerInstance/containerGroups' {

        Require 'ipAddress.type is not Public' {
            Field ipAddress.type | Must -Not -Be 'Public' -IfPresent
        }
    }

    Effect (Param Effect)
}

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