Skip to content

Instantly share code, notes, and snippets.

@zmilleson
Last active October 21, 2019 14:01
Show Gist options
  • Save zmilleson/71aad6f90c155830ae52e10b14e9b448 to your computer and use it in GitHub Desktop.
Save zmilleson/71aad6f90c155830ae52e10b14e9b448 to your computer and use it in GitHub Desktop.
Azure Policy - Require NSGs on all subnets except GatewaySubnet
{
"type": "Microsoft.Authorization/policyDefinitions",
"name": "enforce-nsg-on-subnet-except-gatewaysubnet",
"properties": {
"displayName": "NSG X on every subnet except GatewaySubnet",
"description": "This policy enforces a specific NSG on every subnet except the GatewaySubnet",
"mode": "All",
"parameters": {},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/virtualNetworks/subnets"
},
{
"anyOf": [
{
"field": "name",
"notequals": "GatewaySubnet"
}
]
},
{
"field": "Microsoft.Network/virtualNetworks/subnets/networkSecurityGroup.id",
"exists": "false"
}
]
},
"then": {
"effect": "audit"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment