-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathModify-NSG.json
129 lines (129 loc) · 4.79 KB
/
Modify-NSG.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
{
"name": "Modify-NSG",
"type": "Microsoft.Authorization/policyDefinitions",
"apiVersion": "2021-06-01",
"scope": null,
"properties": {
"policyType": "Custom",
"mode": "All",
"displayName": "Enforce specific configuration of Network Security Groups (NSG)",
"description": "This policy enforces the configuration of Network Security Groups (NSG).",
"metadata": {
"version": "1.0.0",
"category": "Network",
"source": "https://github.com/Azure/Enterprise-Scale/",
"alzCloudEnvironments": [
"AzureCloud",
"AzureChinaCloud",
"AzureUSGovernment"
]
},
"parameters": {
"effect": {
"type": "String",
"allowedValues": [
"Modify",
"Disabled"
],
"defaultValue": "Modify",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
},
"nsgRuleName": {
"type": "string",
"defaultValue": "DenyAnyInternetOutbound"
},
"nsgRulePriority": {
"type": "integer",
"defaultValue": 1000
},
"nsgRuleDirection": {
"type": "string",
"allowedValues": [
"Inbound",
"Outbound"
],
"defaultValue": "Outbound"
},
"nsgRuleAccess": {
"type": "string",
"allowedValues": [
"Allow",
"Deny"
],
"defaultValue": "Deny"
},
"nsgRuleProtocol": {
"type": "string",
"defaultValue": "*"
},
"nsgRuleSourceAddressPrefix": {
"type": "string",
"defaultValue": "*"
},
"nsgRuleSourcePortRange": {
"type": "string",
"defaultValue": "*"
},
"nsgRuleDestinationAddressPrefix": {
"type": "string",
"defaultValue": "Internet"
},
"nsgRuleDestinationPortRange": {
"type": "string",
"defaultValue": "*"
},
"nsgRuleDescription": {
"type": "string",
"defaultValue": "Deny any outbound traffic to the Internet"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/networkSecurityGroups"
},
{
"count": {
"field": "Microsoft.Network/networkSecurityGroups/securityRules[*]"
},
"equals": 0
}
]
},
"then": {
"effect": "[[parameters('effect')]",
"details": {
"roleDefinitionIds": [
"/providers/microsoft.authorization/roleDefinitions/4d97b98b-1d4f-4787-a291-c67834d212e7"
],
"conflictEffect": "audit",
"operations": [
{
"operation": "add",
"field": "Microsoft.Network/networkSecurityGroups/securityRules[*]",
"value": {
"name": "[[parameters('nsgRuleName')]",
"properties": {
"description": "[[parameters('nsgRuleDescription')]",
"protocol": "[[parameters('nsgRuleProtocol')]",
"sourcePortRange": "[[parameters('nsgRuleSourcePortRange')]",
"destinationPortRange": "[[parameters('nsgRuleDestinationPortRange')]",
"sourceAddressPrefix": "[[parameters('nsgRuleSourceAddressPrefix')]",
"destinationAddressPrefix": "[[parameters('nsgRuleDestinationAddressPrefix')]",
"access": "[[parameters('nsgRuleAccess')]",
"priority": "[[parameters('nsgRulePriority')]",
"direction": "[[parameters('nsgRuleDirection')]"
}
}
}
]
}
}
}
}
}