Bylaw

Gallery › Sovereignty › Azure built-in policies

[Preview]: Azure Red Hat OpenShift clusters should disable public network access

Converted Policy Audit Disabled Mode Indexed Version 1.0.0-preview Preview

Disabling public access to the API server and ingress endpoints improves security by ensuring that Azure Red Hat OpenShift clusters aren't exposed on the public internet.

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

Azure Policy JSONAzureRedHatOpenShift_PublicNetworkAccess_Audit.json · 68 lines
{
  "properties": {
    "displayName": "[Preview]: Azure Red Hat OpenShift clusters should disable public network access",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disabling public access to the API server and ingress endpoints improves security by ensuring that Azure Red Hat OpenShift clusters aren't exposed on the public internet.",
    "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",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.RedHatOpenShift/openShiftClusters"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.RedHatOpenShift/openShiftClusters/apiserverProfile.visibility",
                "notEquals": "Private"
              },
              {
                "value": "[empty(field('Microsoft.RedHatOpenShift/openShiftClusters/ingressProfiles'))]",
                "equals": true
              },
              {
                "count": {
                  "field": "Microsoft.RedHatOpenShift/openShiftClusters/ingressProfiles[*]",
                  "where": {
                    "value": "[current('Microsoft.RedHatOpenShift/openShiftClusters/ingressProfiles[*].visibility')]",
                    "notEquals": "Private"
                  }
                },
                "greater": 0
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/a88d4a2c-216a-4fdb-8df0-b8ad54354f57",
  "name": "a88d4a2c-216a-4fdb-8df0-b8ad54354f57"
}
Bylawa88d4a2c-216a-4fdb-8df0-b8ad54354f57.bylaw.ps1 · 39 lines
# Converted from AzureRedHatOpenShift_PublicNetworkAccess_Audit.json by ConvertTo-Bylaw.
Policy 'a88d4a2c-216a-4fdb-8df0-b8ad54354f57' {

    Properties @{
        DisplayName   = '[Preview]: Azure Red Hat OpenShift clusters should disable public network access'
        Description   = 'Disabling public access to the API server and ingress endpoints improves security by ensuring that Azure Red Hat OpenShift clusters aren''t exposed on the public internet.'
        Version       = '1.0.0-preview'
        Category      = 'Sovereignty'
        Preview       = $true
        PolicyVersion = '1.0.0-preview'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.RedHatOpenShift/openShiftClusters' {

        Require 'apiserverProfile.visibility is Private' {
            Field apiserverProfile.visibility | Must -Be 'Private'
        }

        Require 'ingressProfiles is as required' {
            Arm '[empty(field(''Microsoft.RedHatOpenShift/openShiftClusters/ingressProfiles''))]' | Must -Not -Be $true
        }

        Require 'ingressProfiles is as required' {
            Count 'ingressProfiles[*]' -Where {
                Arm '[current(''Microsoft.RedHatOpenShift/openShiftClusters/ingressProfiles[*].visibility'')]' | Must -Not -Be 'Private'
            } | Must -Be 0
        }
    }

    Effect (Param Effect)
}

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