Bylaw

Gallery › Event Grid › Azure Community Policy

Enforce event grid system topic handler type to be storage account

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

This policy enforce event grid system topic handler type to be storage account.

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

Azure Policy JSONazurepolicy.json · 48 lines
{
  "name": "c49bc25e-0d5d-4959-9f56-4267c2d95b8a",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Enforce event grid system topic handler type to be storage account",
    "description": "This policy enforce event grid system topic handler type to be storage account.",
    "metadata": {
      "category": "Event Grid",
      "createdBy": "",
      "updatedBy": null,
      "updatedOn": null,
      "version": "1.0.0"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Deny, Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Deny",
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.EventGrid/systemTopics/eventSubscriptions",
            "field": "type"
          },
          {
            "field": "Microsoft.EventGrid/systemTopics/eventSubscriptions/destination.endpointType",
            "notequals": "StorageQueue"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylawc49bc25e-0d5d-4959-9f56-4267c2d95b8a.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'c49bc25e-0d5d-4959-9f56-4267c2d95b8a' {

    Properties @{
        DisplayName = 'Enforce event grid system topic handler type to be storage account'
        Description = 'This policy enforce event grid system topic handler type to be storage account.'
        Category    = 'Event Grid'
        Version     = '1.0.0'
        Mode        = 'All'
    }

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

    Resource 'Microsoft.EventGrid/systemTopics/eventSubscriptions' {

        Require 'destination.endpointType is StorageQueue' {
            Field destination.endpointType | Must -Be 'StorageQueue'
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Event Grid/enforce-event-grid-system-topic-handler-type-to-be-storage-account/azurepolicy.json in Azure/Community-Policy, under the MIT licence.