-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
AKS_AAD_AdminGroup_DINE.json
228 lines (228 loc) · 14.6 KB
/
AKS_AAD_AdminGroup_DINE.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
{
"properties": {
"policyType": "BuiltIn",
"displayName": "Configure Microsoft Entra ID integrated Azure Kubernetes Service Clusters with required Admin Group Access",
"description": "Ensure to improve cluster security by centrally govern Administrator access to Microsoft Entra ID integrated AKS clusters.",
"metadata": {
"version": "2.1.0",
"category": "Kubernetes"
},
"version": "2.1.0",
"mode": "Indexed",
"parameters": {
"effect": {
"type": "String",
"defaultValue": "DeployIfNotExists",
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy",
"portalReview": true
}
},
"adminGroupObjectIDs": {
"type": "Array",
"metadata": {
"displayName": "AKS Administrator Group Object IDs",
"description": "Array of the existing AKS Administrator Group Object ID to ensure administration access to the cluster. Empty array will remove all admin access.",
"portalReview": true
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.ContainerService/managedClusters"
},
{
"field": "Microsoft.ContainerService/managedClusters/aadProfile",
"exists": true
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.ContainerService/managedClusters",
"name": "[field('name')]",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/ed7f3fbd-7b88-4dd4-9017-9adb7ce333f8",
"/providers/Microsoft.Authorization/roleDefinitions/18ed5180-3e48-46fd-8541-4ea054d57064"
],
"existenceCondition": {
"allOf": [
{
"count": {
"field": "Microsoft.ContainerService/managedClusters/aadProfile.adminGroupObjectIDs[*]",
"where": {
"field": "Microsoft.ContainerService/managedClusters/aadProfile.adminGroupObjectIDs[*]",
"in": "[parameters('adminGroupObjectIDs')]"
}
},
"equals": "[length(parameters('adminGroupObjectIDs'))]"
},
{
"count": {
"field": "Microsoft.ContainerService/managedClusters/aadProfile.adminGroupObjectIDs[*]"
},
"equals": "[length(parameters('adminGroupObjectIDs'))]"
}
]
},
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"clusterName": {
"type": "string"
},
"clusterResourceGroupName": {
"type": "string"
},
"adminGroupObjectIDs": {
"type": "array"
}
},
"variables": {
"clusterGetDeploymentName": "[take(concat('Policy-Get-', parameters('clusterName')), 64)]",
"clusterUpdateDeploymentName": "[take(concat('Policy-Update-', parameters('clusterName')), 64)]"
},
"resources": [
{
"apiVersion": "2020-06-01",
"type": "Microsoft.Resources/deployments",
"name": "[variables('clusterGetDeploymentName')]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [],
"outputs": {
"aksCluster": {
"type": "object",
"value": "[reference(resourceId(parameters('clusterResourceGroupName'), 'Microsoft.ContainerService/managedClusters', parameters('clusterName')), '2023-11-01', 'Full')]"
}
}
}
}
},
{
"apiVersion": "2020-06-01",
"type": "Microsoft.Resources/deployments",
"name": "[variables('clusterUpdateDeploymentName')]",
"properties": {
"mode": "Incremental",
"expressionEvaluationOptions": {
"scope": "inner"
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"aksClusterName": {
"type": "string"
},
"aksClusterContent": {
"type": "object"
},
"adminGroupObjectIDs": {
"type": "array"
}
},
"resources": [
{
"apiVersion": "2023-11-01",
"type": "Microsoft.ContainerService/managedClusters",
"name": "[parameters('aksClusterName')]",
"location": "[parameters('aksClusterContent').location]",
"sku": "[parameters('aksClusterContent').sku]",
"tags": "[if(contains(parameters('aksClusterContent'), 'tags'), parameters('aksClusterContent').tags, json('null'))]",
"properties": {
"kubernetesVersion": "[parameters('aksClusterContent').properties.kubernetesVersion]",
"linuxProfile": "[if(contains(parameters('aksClusterContent').properties, 'linuxProfile'), parameters('aksClusterContent').properties.linuxProfile, json('null'))]",
"windowsProfile": "[if(contains(parameters('aksClusterContent').properties, 'windowsProfile'), parameters('aksClusterContent').properties.windowsProfile, json('null'))]",
"servicePrincipalProfile": "[if(contains(parameters('aksClusterContent').properties, 'servicePrincipalProfile'), parameters('aksClusterContent').properties.servicePrincipalProfile, json('null'))]",
"nodeResourceGroup": "[parameters('aksClusterContent').properties.nodeResourceGroup]",
"enableRBAC": "[if(contains(parameters('aksClusterContent').properties, 'enableRBAC'), parameters('aksClusterContent').properties.enableRBAC, json('null'))]",
"enablePodSecurityPolicy": "[if(contains(parameters('aksClusterContent').properties, 'enablePodSecurityPolicy'), parameters('aksClusterContent').properties.enablePodSecurityPolicy, json('null'))]",
"networkProfile": "[if(contains(parameters('aksClusterContent').properties, 'networkProfile'), parameters('aksClusterContent').properties.networkProfile, json('null'))]",
"aadProfile": {
"adminGroupObjectIds": "[parameters('adminGroupObjectIDs')]",
"managed": "[if(and(contains(parameters('aksClusterContent').properties, 'aadProfile'), contains(parameters('aksClusterContent').properties.aadProfile, 'managed')), parameters('aksClusterContent').properties.aadProfile.managed, json('null'))]",
"enableAzureRBAC": "[if(and(contains(parameters('aksClusterContent').properties, 'aadProfile'), contains(parameters('aksClusterContent').properties.aadProfile, 'enableAzureRBAC')), parameters('aksClusterContent').properties.aadProfile.enableAzureRBAC, json('null'))]",
"tenantID": "[if(and(contains(parameters('aksClusterContent').properties, 'aadProfile'), contains(parameters('aksClusterContent').properties.aadProfile, 'tenantID')), parameters('aksClusterContent').properties.aadProfile.tenantID, json('null'))]",
"clientAppID": "[if(and(contains(parameters('aksClusterContent').properties, 'aadProfile'), contains(parameters('aksClusterContent').properties.aadProfile, 'clientAppID')), parameters('aksClusterContent').properties.aadProfile.clientAppID, json('null'))]",
"serverAppID": "[if(and(contains(parameters('aksClusterContent').properties, 'aadProfile'), contains(parameters('aksClusterContent').properties.aadProfile, 'serverAppID')), parameters('aksClusterContent').properties.aadProfile.serverAppID, json('null'))]",
"serverAppSecret": "[if(and(contains(parameters('aksClusterContent').properties, 'aadProfile'), contains(parameters('aksClusterContent').properties.aadProfile, 'serverAppSecret')), parameters('aksClusterContent').properties.aadProfile.serverAppSecret, json('null'))]"
},
"autoScalerProfile": "[if(contains(parameters('aksClusterContent').properties, 'autoScalerProfile'), parameters('aksClusterContent').properties.autoScalerProfile, json('null'))]",
"autoUpgradeProfile": "[if(contains(parameters('aksClusterContent').properties, 'autoUpgradeProfile'), parameters('aksClusterContent').properties.autoUpgradeProfile, json('null'))]",
"azureMonitorProfile": "[if(contains(parameters('aksClusterContent').properties, 'azureMonitorProfile'), parameters('aksClusterContent').properties.azureMonitorProfile, json('null'))]",
"apiServerAccessProfile": "[if(contains(parameters('aksClusterContent').properties, 'apiServerAccessProfile'), parameters('aksClusterContent').properties.apiServerAccessProfile, json('null'))]",
"diskEncryptionSetID": "[if(contains(parameters('aksClusterContent').properties, 'diskEncryptionSetID'), parameters('aksClusterContent').properties.diskEncryptionSetID, json('null'))]",
"disableLocalAccounts": "[if(contains(parameters('aksClusterContent').properties, 'disableLocalAccounts'), parameters('aksClusterContent').properties.disableLocalAccounts, json('null'))]",
"fqdnSubdomain": "[if(contains(parameters('aksClusterContent').properties, 'fqdnSubdomain'), parameters('aksClusterContent').properties.fqdnSubdomain, json('null'))]",
"httpProxyConfig": "[if(contains(parameters('aksClusterContent').properties, 'httpProxyConfig'), parameters('aksClusterContent').properties.httpProxyConfig, json('null'))]",
"oidcIssuerProfile": "[if(contains(parameters('aksClusterContent').properties, 'oidcIssuerProfile'), parameters('aksClusterContent').properties.oidcIssuerProfile, json('null'))]",
"podIdentityProfile": "[if(contains(parameters('aksClusterContent').properties, 'podIdentityProfile'), parameters('aksClusterContent').properties.podIdentityProfile, json('null'))]",
"privateLinkResources": "[if(contains(parameters('aksClusterContent').properties, 'privateLinkResources'), parameters('aksClusterContent').properties.privateLinkResources, json('null'))]",
"identityProfile": "[if(contains(parameters('aksClusterContent').properties, 'identityProfile'), parameters('aksClusterContent').properties.identityProfile, json('null'))]",
"publicNetworkAccess": "[if(contains(parameters('aksClusterContent').properties, 'publicNetworkAccess'), parameters('aksClusterContent').properties.publicNetworkAccess, json('null'))]",
"serviceMeshProfile": "[if(contains(parameters('aksClusterContent').properties, 'serviceMeshProfile'), parameters('aksClusterContent').properties.serviceMeshProfile, json('null'))]",
"storageProfile": "[if(contains(parameters('aksClusterContent').properties, 'storageProfile'), parameters('aksClusterContent').properties.storageProfile, json('null'))]",
"supportPlan": "[if(contains(parameters('aksClusterContent').properties, 'supportPlan'), parameters('aksClusterContent').properties.supportPlan, json('null'))]",
"upgradeSettings": "[if(contains(parameters('aksClusterContent').properties, 'upgradeSettings'), parameters('aksClusterContent').properties.upgradeSettings, json('null'))]",
"workloadAutoScalerProfile": "[if(contains(parameters('aksClusterContent').properties, 'workloadAutoScalerProfile'), parameters('aksClusterContent').properties.workloadAutoScalerProfile, json('null'))]"
}
}
],
"outputs": {}
},
"parameters": {
"aksClusterName": {
"value": "[parameters('clusterName')]"
},
"aksClusterContent": {
"value": "[reference(variables('clusterGetDeploymentName')).outputs.aksCluster.value]"
},
"adminGroupObjectIDs": {
"value": "[parameters('adminGroupObjectIDs')]"
}
}
}
}
]
},
"parameters": {
"clusterName": {
"value": "[field('name')]"
},
"clusterResourceGroupName": {
"value": "[resourceGroup().name]"
},
"adminGroupObjectIDs": {
"value": "[parameters('adminGroupObjectIDs')]"
}
}
}
}
}
}
},
"versions": [
"2.1.0",
"2.0.4"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/36a27de4-199b-40fb-b336-945a8475d6c5",
"name": "36a27de4-199b-40fb-b336-945a8475d6c5"
}