forked from fawohlsc/azure-policy-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeny-Route-NextHopVirtualAppliance.json
134 lines (134 loc) · 6.48 KB
/
Deny-Route-NextHopVirtualAppliance.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"variables": {
"policyName": "Deny-Route-NextHopVirtualAppliance",
"policyDescription": "Deny route with address prefix 0.0.0.0/0 not pointing to the virtual appliance. Both creating routes as a standalone resource or nested within their parent resource route table are considered.",
"policyCategory": "Network",
"policyAssignmentParameters": {
"routeTableSettings": {
"value": {
"northeurope": {
"virtualApplianceIpAddress": "10.0.0.23"
},
"westeurope": {
"virtualApplianceIpAddress": "10.1.0.23"
},
"disabled": {
"virtualApplianceIpAddress": ""
}
}
}
}
},
"resources": [
{
"name": "[variables('policyName')]",
"type": "Microsoft.Authorization/policyDefinitions",
"apiVersion": "2020-03-01",
"properties": {
"policyType": "Custom",
"mode": "All",
"displayName": "[variables('policyName')]",
"description": "[variables('policyDescription')]",
"metadata": {
"category": "[variables('policyCategory')]"
},
"parameters": {
"routeTableSettings": {
"type": "Object",
"metadata": {
"displayName": "Route Table Settings",
"description": "Location-specific settings for route tables."
}
}
},
"policyRule": {
"if": {
"anyOf": [
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/routeTables"
},
{
"count": {
"field": "Microsoft.Network/routeTables/routes[*]",
"where": {
"allOf": [
{
"field": "Microsoft.Network/routeTables/routes[*].addressPrefix",
"equals": "0.0.0.0/0"
},
{
"anyOf": [
{
"field": "Microsoft.Network/routeTables/routes[*].nextHopType",
"notEquals": "VirtualAppliance"
},
{
"field": "Microsoft.Network/routeTables/routes[*].nextHopIpAddress",
"notEquals": "[[parameters('routeTableSettings')[field('location')].virtualApplianceIpAddress]"
}
]
}
]
}
},
"greater": 0
}
]
},
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/routeTables/routes"
},
{
"field": "Microsoft.Network/routeTables/routes/addressPrefix",
"equals": "0.0.0.0/0"
},
{
"anyOf": [
{
"field": "Microsoft.Network/routeTables/routes/nextHopType",
"notEquals": "VirtualAppliance"
},
{
"field": "Microsoft.Network/routeTables/routes/nextHopIpAddress",
"notEquals": "[[parameters('routeTableSettings')[field('location')].virtualApplianceIpAddress]"
}
]
}
]
}
]
},
"then": {
"effect": "deny"
}
}
}
},
{
"name": "[uniqueString(variables('policyName'))]",
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-03-01",
"properties": {
"displayName": "[variables('policyName')]",
"policyDefinitionId": "[resourceId('Microsoft.Authorization/policyDefinitions', variables('policyName'))]",
"parameters": "[variables('policyAssignmentParameters')]",
"description": "[variables('policyDescription')]",
"metadata": {
"category": "[variables('policyCategory')]"
},
"enforcementMode": "Default"
},
"dependsOn": [
"[resourceId('Microsoft.Authorization/policyDefinitions', variables('policyName'))]"
]
}
]
}