-
Notifications
You must be signed in to change notification settings - Fork 6
/
azdeploy.json
80 lines (80 loc) · 3.04 KB
/
azdeploy.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
{
"properties": {
"displayName": "Azure resource groups should be locked - Audit and deploy lock",
"policyType": "Custom",
"mode": "All",
"description": "This policy audits any azure resource group and audit, if the RG is locked. If not, a lock will be deployed automatically. You can exclude RGs from the audit based on a tag you define",
"metadata": {
"version": "0.3.0",
"category": "Governance"
},
"parameters": {
"TagOfExclusion": {
"type":"String",
"metadata": {
"displayName": "Tag to check for exclusion",
"description": "If there is a need to exclude RGs from the audit based on a tag, you can do so. In this field, define which tag you want to check for it's value."
},
"defaultValue": "AutoLockExclusion"
},
"TagValue": {
"type":"String",
"metadata":{
"displayName": "Value of the tag for exclusion",
"description": "If you decided to configure an exclusion, you need to configure a specific value of the tag you defined. Put the tag value for exclusion in this field"
},
"defaultValue": "true"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions/resourceGroups"
},
{
"not": {
"field": "[concat('tags[', parameters('TagOfExclusion'), ']')]",
"equals": "[parameters('TagValue')]"
}
}
]
},
"then": {
"effect": "deployIfNotExists",
"details": {
"type": "Microsoft.Authorization/locks",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/8e3af657-a8ff-443c-a75c-2fe8c4bcb635"
],
"existenceCondition": {
"field": "Microsoft.Authorization/locks/level",
"equals": "CanNotDelete"
},
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "Auto locked by policy",
"type": "Microsoft.Authorization/locks",
"apiVersion": "2017-04-01",
"properties": {
"level": "CanNotDelete",
"notes": "This lock was deployed automatically by Azure Policy to prevent the resource group and its containing resources from accidental deletion."
}
}
]
}
}
}
}
}
}
},
"type": "Microsoft.Authorization/policyDefinitions"
}