Gallery › Network › Azure Community Policy
Prevent internet routes in route tables
Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0
This policy prevents next hop internet in route tables.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 70 lines
{
"name": "4a9409bb-2709-4082-ae85-8df50a8f724a",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Prevent internet routes in route tables",
"description": "This policy prevents next hop internet in route tables.",
"metadata": {
"category": "Network",
"createdBy": "",
"updatedBy": null,
"updatedOn": null,
"version": "1.0.0"
},
"mode": "Indexed",
"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": {
"anyOf": [
{
"allOf": [
{
"equals": "Microsoft.Network/routeTables",
"field": "type"
},
{
"count": {
"field": "Microsoft.Network/routeTables/routes[*]",
"where": {
"equals": "Internet",
"field": "Microsoft.Network/routeTables/routes[*].nextHopType"
}
},
"greater": 0
}
]
},
{
"allOf": [
{
"equals": "Microsoft.Network/routeTables/routes",
"field": "type"
},
{
"equals": "Internet",
"field": "Microsoft.Network/routeTables/routes/nextHopType"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw4a9409bb-2709-4082-ae85-8df50a8f724a.bylaw.ps1 · 39 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '4a9409bb-2709-4082-ae85-8df50a8f724a' {
Properties @{
DisplayName = 'Prevent internet routes in route tables'
Description = 'This policy prevents next hop internet in route tables.'
Category = 'Network'
Version = '1.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource * {
Require 'type, routes and nextHopType are as required' {
AnyOf {
Field type | Must -Not -Be 'Microsoft.Network/routeTables' -IfPresent
Each 'Microsoft.Network/routeTables/routes[*]' {
Field nextHopType | Must -Not -Be 'Internet'
}
}
}
Require 'type and nextHopType are as required' {
AnyOf {
Field type | Must -Not -Be 'Microsoft.Network/routeTables/routes' -IfPresent
Field 'Microsoft.Network/routeTables/routes/nextHopType' | Must -Not -Be 'Internet' -IfPresent
}
}
}
Effect (Param Effect)
}Source: policyDefinitions/Network/prevent-internet-routes-in-route-tables/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw