Bylaw

Gallery › Sovereignty › Azure built-in policies

[Preview]: Azure Migrate projects should use private endpoints

Converted Policy Audit Disabled Mode Indexed Version 1.0.0-preview Preview

Azure Private Link lets you connect your virtual networks to Azure services without a public IP address at the source or destination. By requiring an approved private endpoint connection for Azure Migrate projects, you can reduce data leakage risks.

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

Azure Policy JSONAzureMigrate_PrivateEndpoint_Audit.json · 78 lines
{
  "properties": {
    "displayName": "[Preview]: Azure Migrate projects should use private endpoints",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Azure Private Link lets you connect your virtual networks to Azure services without a public IP address at the source or destination. By requiring an approved private endpoint connection for Azure Migrate projects, you can reduce data leakage risks.",
    "metadata": {
      "version": "1.0.0-preview",
      "preview": true,
      "category": "Sovereignty"
    },
    "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": {
        "anyOf": [
          {
            "allOf": [
              {
                "field": "type",
                "equals": "Microsoft.Migrate/assessmentProjects"
              },
              {
                "count": {
                  "field": "Microsoft.Migrate/assessmentProjects/privateEndpointConnections[*]",
                  "where": {
                    "field": "Microsoft.Migrate/assessmentProjects/privateEndpointConnections[*].privateLinkServiceConnectionState.status",
                    "equals": "Approved"
                  }
                },
                "less": 1
              }
            ]
          },
          {
            "allOf": [
              {
                "field": "type",
                "equals": "Microsoft.Migrate/migrateProjects"
              },
              {
                "count": {
                  "field": "Microsoft.Migrate/migrateProjects/privateEndpointConnections[*]",
                  "where": {
                    "field": "Microsoft.Migrate/migrateProjects/privateEndpointConnections[*].privateLinkServiceConnectionState.status",
                    "equals": "Approved"
                  }
                },
                "less": 1
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/54e3763b-72a6-4c12-af2e-544b39d6bfee",
  "name": "54e3763b-72a6-4c12-af2e-544b39d6bfee"
}
Bylaw54e3763b-72a6-4c12-af2e-544b39d6bfee.bylaw.ps1 · 43 lines
# Converted from AzureMigrate_PrivateEndpoint_Audit.json by ConvertTo-Bylaw.
Policy '54e3763b-72a6-4c12-af2e-544b39d6bfee' {

    Properties @{
        DisplayName   = '[Preview]: Azure Migrate projects should use private endpoints'
        Description   = 'Azure Private Link lets you connect your virtual networks to Azure services without a public IP address at the source or destination. By requiring an approved private endpoint connection for Azure Migrate projects, you can reduce data leakage risks.'
        Version       = '1.0.0-preview'
        Preview       = $true
        Category      = 'Sovereignty'
        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 * {

        Require 'type, privateEndpointConnections and privateLinkServiceConnectionState.status are as required' {
            AnyOf {
                Field type | Must -Not -Be 'Microsoft.Migrate/assessmentProjects' -IfPresent
                Count 'Microsoft.Migrate/assessmentProjects/privateEndpointConnections[*]' -Where {
                    Field privateLinkServiceConnectionState.status | Must -Be 'Approved'
                } | Must -BeGreaterOrEqual 1
            }
        }

        Require 'type, privateEndpointConnections and privateLinkServiceConnectionState.status are as required' {
            AnyOf {
                Field type | Must -Not -Be 'Microsoft.Migrate/migrateProjects' -IfPresent
                Count 'Microsoft.Migrate/migrateProjects/privateEndpointConnections[*]' -Where {
                    Field privateLinkServiceConnectionState.status | Must -Be 'Approved'
                } | Must -BeGreaterOrEqual 1
            }
        }
    }

    Effect (Param Effect)
}

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