Bylaw

Gallery › VirtualEnclaves › Azure built-in policies

Do not allow creation of specified resource types or types under specific providers

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

The resource providers and types specified via parameter list are not allowed to be created without explicit approval from the security team. If an exemption is granted to the policy assignment, the resource can be leveraged within the enclave. https://aka.ms/VirtualEnclaves

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

Azure Policy JSONDeniedResourceTypesAndProviders_Deny.json · 80 lines
{
  "properties": {
    "displayName": "Do not allow creation of specified resource types or types under specific providers",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "The resource providers and types specified via parameter list are not allowed to be created without explicit approval from the security team. If an exemption is granted to the policy assignment, the resource can be leveraged within the enclave. https://aka.ms/VirtualEnclaves",
    "metadata": {
      "version": "1.0.0",
      "category": "VirtualEnclaves"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "The effect determines what happens when the policy rule is evaluated to match"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny"
      },
      "disallowedResourceProviders": {
        "metadata": {
          "description": "List of disallowed resource providers or parent resource types as strings, such as microsoft.storage or microsoft.servicebus",
          "displayName": "Denied resource providers"
        },
        "defaultValue": [],
        "type": "Array"
      },
      "disallowedResourceTypes": {
        "metadata": {
          "description": "List of disallowed resource types as strings, such as microsoft.storage/storageaccounts",
          "displayName": "Denied resource types"
        },
        "defaultValue": [],
        "type": "Array"
      }
    },
    "policyRule": {
      "if": {
        "anyOf": [
          {
            "count": {
              "value": "[parameters('disallowedResourceTypes')]",
              "name": "resourceType",
              "where": {
                "field": "type",
                "equals": "[current('resourceType')]"
              }
            },
            "greater": 0
          },
          {
            "count": {
              "value": "[parameters('disallowedResourceProviders')]",
              "name": "resourceProvider",
              "where": {
                "field": "type",
                "like": "[concat(current('resourceProvider'), '/*')]"
              }
            },
            "greater": 0
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/337ef0ec-0703-499e-a57c-b4155034e606",
  "name": "337ef0ec-0703-499e-a57c-b4155034e606"
}
Bylaw337ef0ec-0703-499e-a57c-b4155034e606.bylaw.ps1 · 48 lines
# Converted from DeniedResourceTypesAndProviders_Deny.json by ConvertTo-Bylaw.
Policy '337ef0ec-0703-499e-a57c-b4155034e606' {

    Properties @{
        DisplayName   = 'Do not allow creation of specified resource types or types under specific providers'
        Description   = 'The resource providers and types specified via parameter list are not allowed to be created without explicit approval from the security team. If an exemption is granted to the policy assignment, the resource can be leveraged within the enclave. https://aka.ms/VirtualEnclaves'
        Version       = '1.0.0'
        Category      = 'VirtualEnclaves'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Deny'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }
    Parameter DisallowedResourceProviders @{
        Type        = 'Array'
        Default     = @()
        DisplayName = 'Denied resource providers'
        Description = 'List of disallowed resource providers or parent resource types as strings, such as microsoft.storage or microsoft.servicebus'
    }
    Parameter DisallowedResourceTypes @{
        Type        = 'Array'
        Default     = @()
        DisplayName = 'Denied resource types'
        Description = 'List of disallowed resource types as strings, such as microsoft.storage/storageaccounts'
    }

    Resource * {

        Require 'type is as required' {
            Count -Value (Param DisallowedResourceTypes) -Name resourceType -Where {
                Field type | Must -Be (Current resourceType)
            } | Must -Be 0
        }

        Require 'type is as required' {
            Count -Value (Param DisallowedResourceProviders) -Name resourceProvider -Where {
                Field type | Must -BeLike (Arm '[concat(current(''resourceProvider''), ''/*'')]')
            } | Must -Be 0
        }
    }

    Effect (Param Effect)
}

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