Bylaw

Gallery › Sandbox › Azure Landing Zones Library

Enforce policies in the Sandbox Landing Zone

Converted Initiative Version 1.1.0

Enforce policies in the Sandbox Landing Zone.

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

Azure Policy JSONEnforce-ALZ-Sandbox.alz_policy_set_definition.json · 83 lines
{
  "name": "Enforce-ALZ-Sandbox",
  "properties": {
    "description": "Enforce policies in the Sandbox Landing Zone.",
    "displayName": "Enforce policies in the Sandbox Landing Zone",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Sandbox",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.1.0"
    },
    "parameters": {
      "effectDenyVnetPeering": {
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny",
        "metadata": {
          "description": "Enable or disable the execution of the policy",
          "displayName": "Effect"
        },
        "type": "String"
      },
      "effectNotAllowedResources": {
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny",
        "metadata": {
          "description": "Enable or disable the execution of the policy",
          "displayName": "Effect"
        },
        "type": "String"
      },
      "listOfResourceTypesNotAllowed": {
        "defaultValue": [],
        "metadata": {
          "description": "Not allowed resource types in the Sandbox landing zone, default is none.",
          "displayName": "Not allowed resource types in the Sandbox landing zone",
          "strongType": "resourceTypes"
        },
        "type": "Array"
      }
    },
    "policyDefinitions": [
      {
        "definitionVersion": "2.*.*",
        "groupNames": [],
        "parameters": {
          "effect": {
            "value": "[parameters('effectNotAllowedResources')]"
          },
          "listOfResourceTypesNotAllowed": {
            "value": "[parameters('listOfResourceTypesNotAllowed')]"
          }
        },
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/6c112d4e-5bc7-47ae-a041-ea2d9dccd749",
        "policyDefinitionReferenceId": "SandboxNotAllowed"
      },
      {
        "definitionVersion": "1.*.*",
        "groupNames": [],
        "parameters": {
          "effect": {
            "value": "[parameters('effectDenyVnetPeering')]"
          }
        },
        "policyDefinitionId": "/providers/Microsoft.Management/managementGroups/contoso/providers/Microsoft.Authorization/policyDefinitions/Deny-VNET-Peer-Cross-Sub",
        "policyDefinitionReferenceId": "SandboxDenyVnetPeering"
      }
    ],
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policySetDefinitions"
}
BylawEnforce-ALZ-Sandbox.bylaw.ps1 · 50 lines
# Converted from Enforce-ALZ-Sandbox.alz_policy_set_definition.json by ConvertTo-Bylaw.
Initiative 'Enforce-ALZ-Sandbox' {

    Properties @{
        DisplayName = 'Enforce policies in the Sandbox Landing Zone'
        Description = 'Enforce policies in the Sandbox Landing Zone.'
        Category    = 'Sandbox'
        Version     = '1.1.0'
        Metadata    = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/' }
    }

    Parameter EffectDenyVnetPeering @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Deny'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }
    Parameter EffectNotAllowedResources @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Deny'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }
    Parameter ListOfResourceTypesNotAllowed @{
        Type        = 'Array'
        Default     = @()
        DisplayName = 'Not allowed resource types in the Sandbox landing zone'
        Description = 'Not allowed resource types in the Sandbox landing zone, default is none.'
        Metadata    = [ordered]@{ strongType = 'resourceTypes' }
    }

    PolicyDefinition @{
        Id          = '6c112d4e-5bc7-47ae-a041-ea2d9dccd749'
        ReferenceId = 'SandboxNotAllowed'
        Version     = '2.*.*'
        Parameters  = [ordered]@{
            effect                        = (Param EffectNotAllowedResources)
            listOfResourceTypesNotAllowed = (Param ListOfResourceTypesNotAllowed)
        }
    }

    PolicyDefinition @{
        Id          = '/providers/Microsoft.Management/managementGroups/contoso/providers/Microsoft.Authorization/policyDefinitions/Deny-VNET-Peer-Cross-Sub'
        ReferenceId = 'SandboxDenyVnetPeering'
        Version     = '1.*.*'
        Parameters  = @{
            effect = (Param EffectDenyVnetPeering)
        }
    }
}

Members (2)

Source: policy_set_definitions/Enforce-ALZ-Sandbox.alz_policy_set_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.