Bylaw

Gallery › Sovereignty › Azure built-in policies

[Preview]: Enforce Data Residency across Azure Services

Converted Initiative Version 1.1.0-preview Preview

Help restrict and audit the Azure Regions that Azure Services can be deployed into. Helping to enforce Level 1 - Data Residency Sovereignty Controls detailed here: https://aka.ms/sovereign/controls

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

Azure Policy JSONEnforceDataResidency.json · 107 lines
{
  "properties": {
    "displayName": "[Preview]: Enforce Data Residency across Azure Services",
    "policyType": "BuiltIn",
    "description": "Help restrict and audit the Azure Regions that Azure Services can be deployed into. Helping to enforce Level 1 - Data Residency Sovereignty Controls detailed here: https://aka.ms/sovereign/controls",
    "metadata": {
      "version": "1.1.0-preview",
      "category": "Sovereignty",
      "preview": true,
      "SovereigntyLevel": "Level 1 - Data Residency"
    },
    "version": "1.1.0-preview",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "This parameter lets you choose the effect of the policy. If you choose Audit, the policy will only audit resources for compliance. If you choose Deny (default), the policy will deny the creation of non-compliant resources. If you choose Disabled, the policy will not enforce compliance (useful, for example, as a second assignment to ignore a subset of non-compliant resources in a single resource group)."
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny"
      },
      "listOfAllowedLocations": {
        "type": "Array",
        "metadata": {
          "description": "The list of locations (Azure Regions) that can be specified when deploying resources and resource groups.",
          "strongType": "location",
          "displayName": "Allowed locations (regions)"
        }
      }
    },
    "policyDefinitions": [
      {
        "policyDefinitionReferenceId": "allowedLocations",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/e56962a6-4747-49cd-b67b-bf8b01975c4c",
        "definitionVersion": "1.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "listOfAllowedLocations": {
            "value": "[parameters('listOfAllowedLocations')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "allowedLocationsResourceGroups",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988",
        "definitionVersion": "1.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "listOfAllowedLocations": {
            "value": "[parameters('listOfAllowedLocations')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "allowedLocationsCommunicationsServices",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/93c45b74-42a1-4967-b25d-82c4dc630921",
        "definitionVersion": "1.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "allowedDataLocations": {
            "value": "[parameters('listOfAllowedLocations')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "allowedLocationsMaps",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/c707daa0-b93b-454d-9e1e-8ac59866316c",
        "definitionVersion": "1.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "listOfAllowedLocations": {
            "value": "[parameters('listOfAllowedLocations')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "storageAccountCrossTenantReplication",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/92a89a79-6c52-4a7e-a03f-61306fc49312",
        "definitionVersion": "1.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          }
        }
      }
    ],
    "versions": [
      "1.1.0-PREVIEW",
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policySetDefinitions/bebfcba2-e789-4da6-9043-726ef3a00d02",
  "name": "bebfcba2-e789-4da6-9043-726ef3a00d02"
}
Bylawbebfcba2-e789-4da6-9043-726ef3a00d02.bylaw.ps1 · 75 lines
# Converted from EnforceDataResidency.json by ConvertTo-Bylaw.
Initiative 'bebfcba2-e789-4da6-9043-726ef3a00d02' {

    Properties @{
        DisplayName   = '[Preview]: Enforce Data Residency across Azure Services'
        Description   = 'Help restrict and audit the Azure Regions that Azure Services can be deployed into. Helping to enforce Level 1 - Data Residency Sovereignty Controls detailed here: https://aka.ms/sovereign/controls'
        Version       = '1.1.0-preview'
        Category      = 'Sovereignty'
        Preview       = $true
        PolicyVersion = '1.1.0-preview'
        Metadata      = [ordered]@{ SovereigntyLevel = 'Level 1 - Data Residency' }
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Deny'
        DisplayName   = 'Effect'
        Description   = 'This parameter lets you choose the effect of the policy. If you choose Audit, the policy will only audit resources for compliance. If you choose Deny (default), the policy will deny the creation of non-compliant resources. If you choose Disabled, the policy will not enforce compliance (useful, for example, as a second assignment to ignore a subset of non-compliant resources in a single resource group).'
    }
    Parameter ListOfAllowedLocations @{
        Type        = 'Array'
        DisplayName = 'Allowed locations (regions)'
        Description = 'The list of locations (Azure Regions) that can be specified when deploying resources and resource groups.'
        Metadata    = [ordered]@{ strongType = 'location' }
    }

    PolicyDefinition @{
        Id          = 'e56962a6-4747-49cd-b67b-bf8b01975c4c'
        ReferenceId = 'allowedLocations'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            effect                 = (Param Effect)
            listOfAllowedLocations = (Param ListOfAllowedLocations)
        }
    }

    PolicyDefinition @{
        Id          = 'e765b5de-1225-4ba3-bd56-1ac6695af988'
        ReferenceId = 'allowedLocationsResourceGroups'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            effect                 = (Param Effect)
            listOfAllowedLocations = (Param ListOfAllowedLocations)
        }
    }

    PolicyDefinition @{
        Id          = '93c45b74-42a1-4967-b25d-82c4dc630921'
        ReferenceId = 'allowedLocationsCommunicationsServices'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            effect               = (Param Effect)
            allowedDataLocations = (Param ListOfAllowedLocations)
        }
    }

    PolicyDefinition @{
        Id          = 'c707daa0-b93b-454d-9e1e-8ac59866316c'
        ReferenceId = 'allowedLocationsMaps'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            effect                 = (Param Effect)
            listOfAllowedLocations = (Param ListOfAllowedLocations)
        }
    }

    PolicyDefinition @{
        Id          = '92a89a79-6c52-4a7e-a03f-61306fc49312'
        ReferenceId = 'storageAccountCrossTenantReplication'
        Version     = '1.*.*'
        Parameters  = @{
            effect = (Param Effect)
        }
    }
}

Members (5)

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