Gallery › Event Hub › Azure Community Policy
Event Hub firewall should only allow certain IPs
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
This policy allows only restricted IPs for Event hub firewall
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 63 lines
{
"name": "bcb95ef4-f1df-414d-ac57-8a4e308512ba",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Event Hub firewall should only allow certain IPs",
"description": "This policy allows only restricted IPs for Event hub firewall",
"metadata": {
"version": "1.0.0",
"category": "Event Hub"
},
"mode": "All",
"parameters": {
"allowedIps": {
"type": "Array",
"metadata": {
"displayName": "Allow IPs for event hub firewall",
"description": "List of IPs allowed for event hub firewall"
},
"defaultValue": []
},
"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": [
{
"field": "type",
"equals": "Microsoft.EventHub/namespaces/networkRuleSets"
},
{
"anyOf": [
{
"field": "Microsoft.EventHub/namespaces/networkRuleSets/default.defaultAction",
"equals": "Allow"
},
{
"not": {
"field": "Microsoft.EventHub/namespaces/networkRuleSets/default.ipRules[*].ipMask",
"in": "[parameters('allowedIps')]"
}
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawbcb95ef4-f1df-414d-ac57-8a4e308512ba.bylaw.ps1 · 40 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'bcb95ef4-f1df-414d-ac57-8a4e308512ba' {
Properties @{
DisplayName = 'Event Hub firewall should only allow certain IPs'
Description = 'This policy allows only restricted IPs for Event hub firewall'
Version = '1.0.0'
Category = 'Event Hub'
Mode = 'All'
}
Parameter AllowedIps @{
Type = 'Array'
Default = @()
DisplayName = 'Allow IPs for event hub firewall'
Description = 'List of IPs allowed for event hub firewall'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.EventHub/namespaces/networkRuleSets' {
Require 'default.defaultAction is not Allow' {
Field default.defaultAction | Must -Not -Be 'Allow' -IfPresent
}
Require 'default.ipRules and ipMask are as required' {
Field default.ipRules | Must -Exist
Each 'default.ipRules[*]' {
Field ipMask | Must -BeIn (Param AllowedIps) -Strict
}
}
}
Effect (Param Effect)
}Source: policyDefinitions/Event Hub/event-hub-firewall-should-only-allow-certain-ips/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw