forked from nitinkhandelwal26/aks-baseline-regulated
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubscription.json
More file actions
855 lines (852 loc) · 51.9 KB
/
subscription.json
File metadata and controls
855 lines (852 loc) · 51.9 KB
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
/* Required Permissions
- Scope: Subscription
Role: Contributor
Reason: Creating resource groups, azure policy definations and assignments
Optional Permissions
- Scope: Subscription
Role: Security Admin (or Owner)
Reason: To enable Azure Defender for Kubernetes, Container Registry, and Key Vault.
Notes: If unable to obtain permissions, you must pass false to the enableAzureDefender parameter or have someone else enable these for you.
*/
"parameters": {
"enforceAzureDefenderAutoDeployPolicies": {
"type": "bool",
"defaultValue": true,
"metadata": {
"description": "By default Azure Defender for Kubernetes Service, Container Registry, and Key Vault are configured to deploy via Azure Policy, use this parameter to disable that."
}
},
"enableAzureDefender": {
"type": "bool",
"defaultValue": true,
"metadata": {
"description": "By default Azure Defender for Kubernetes Service, Container Registry, and Key Vault are enabled; use this parameter to prevent them from being enabled. Deploying these requires subscription Owner or Security Admin roles."
}
},
"networkWatcherRGRegion": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "networkWatcherRG often times already exists in a subscription. Empty string will result in using the default resource location."
}
}
},
"variables": {
"rgName-Hubs": "rg-enterprise-networking-hubs",
"rgName-Spokes": "rg-enterprise-networking-spokes",
"rgName-NetworkWatchers": "networkWatcherRG",
"rgName-bu0001A0005": "rg-bu0001a0005",
"policyDefinitionId-AllowedResources": "/providers/Microsoft.Authorization/policyDefinitions/a08ec900-254a-4555-9bf5-e42af04b5c5c",
"policyDefinitionId-DenyAksWithoutPolicy": "/providers/Microsoft.Authorization/policyDefinitions/0a15ec92-a229-4763-bb14-0ea34a568f8d",
"policyDefinitionId-DenyAksWithoutRbac": "/providers/Microsoft.Authorization/policyDefinitions/ac4a19c2-fa67-49b4-8ae5-0b2e78c49457",
"policyDefinitionId-DenyOldAks": "/providers/Microsoft.Authorization/policyDefinitions/fb893a29-21bb-418c-a157-e99480ec364c",
"policyDefinitionId-CustomerManagedEncryption": "/providers/Microsoft.Authorization/policyDefinitions/7d7be79c-23ba-4033-84dd-45e2a5ccdd67",
"policyDefinitionId-EncryptionAtHost": "/providers/Microsoft.Authorization/policyDefinitions/41425d9f-d1a5-499a-9932-f8ed8453932c",
"policyDefinitionId-NetworkWatcherShouldBeEnabled": "/providers/Microsoft.Authorization/policyDefinitions/b6e2945c-0b7b-40f5-9233-7a5323b5cdc6",
"policyDefinitionName-EnableAksDefender": "[guid(subscription().id, 'EnableDefenderForAks')]",
"policyDefinitionName-EnableAcrDefender": "[guid(subscription().id, 'EnableDefenderForAcr')]",
"policyDefinitionName-EnableAkvDefender": "[guid(subscription().id, 'EnableDefenderForAkv')]",
"policyDefinitionName-DenyPublicAks": "[guid(subscription().id, 'DenyPublicAks')]",
"policyDefinitionName-DenyAksWithoutPolicy": "[guid(subscription().id, 'DenyAksWithoutPolicy')]",
"policyDefinitionName-DenyAagWithoutWaf": "[guid(subscription().id, 'DenyAagWithoutWaf')]",
"policyDefinitionName-DenyAksWithoutRbac": "[guid(subscription().id, 'DenyAksWithoutRbac')]",
"policyDefinitionName-DenyOldAks": "[guid(subscription().id, 'DenyOldAksVersions')]",
"policyDefinitionName-CustomerManagedEncryption": "[guid(subscription().id, 'CustomerManagedEncryption')]",
"policyDefinitionName-EncryptionAtHost": "[guid(subscription().id, 'EncryptionAtHost')]",
"policyDefinitionName-NoPublicIPsForNICsInVnet": "[guid(subscription().id, 'NoPublicIPsForNICsInVnet')]",
"policyDefinitionName-NoPublicIPsForVMScaleSets": "[guid(subscription().id, 'NoPublicIPsForVMScaleSets')]",
"policySetDefinitionName-EnableDefender": "[guid(subscription().id, 'EnableDefender')]",
"roleId-SecurityAdmin": "/providers/Microsoft.Authorization/roleDefinitions/fb1c8493-542b-48eb-b624-b4c8fea62acd",
"deploymentResourceRegion": "centralus" // This region is used as the default for all generic resource groups and for any additional deployment resources. No resources are actually deployed to this resource group.
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2020-10-01",
"name": "[variables('rgName-Hubs')]",
"location": "[variables('deploymentResourceRegion')]",
"comments": "This contains all of our regional hubs. Typically this would be found in your enterprise's Connectivity subscription."
},
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2020-10-01",
"name": "[variables('rgName-Spokes')]",
"location": "[variables('deploymentResourceRegion')]",
"comments": "This contains all of our regional spokes. Typically this would be found in your enterprise's Connectivity subscription or in the workload's subscription."
},
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2020-10-01",
"name": "[variables('rgName-bu0001A0005')]",
"location": "[variables('deploymentResourceRegion')]",
"comments": "This is the resource group for BU001A0005. Typically this would be found in your workload's subscription."
},
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2020-10-01",
"name": "[variables('rgName-NetworkWatchers')]",
"location": "[if(empty(parameters('networkWatcherRGRegion')), variables('deploymentResourceRegion'), parameters('networkWatcherRGRegion'))]",
"comments": "This is the resource group for Azure Network Watchers. Most subscriptions already have this."
},
{
"type": "Microsoft.Authorization/policyDefinitions",
"apiVersion": "2019-09-01",
"name": "[variables('policyDefinitionName-EnableAksDefender')]",
"properties": {
"displayName": "Azure Defender for Kubernetes is enabled",
"policyType": "Custom",
"mode": "All",
"description": "Azure Defender for Kubernetes provides real-time threat protection for containerized environments and generates alerts for suspicious activities.",
"metadata": {
"version": "1.0.0",
"category": "Security Center"
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions"
}
]
},
"then": {
"effect": "deployIfNotExists",
"details": {
"type": "Microsoft.Security/pricings",
"name": "KubernetesService",
"deploymentScope": "subscription",
"existenceScope": "subscription",
"roleDefinitionIds": [
"[variables('roleId-SecurityAdmin')]"
],
"existenceCondition": {
"field": "Microsoft.Security/pricings/pricingTier",
"equals": "Standard"
},
"deployment": {
"location": "[variables('deploymentResourceRegion')]",
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Security/pricings",
"apiVersion": "2018-06-01",
"name": "KubernetesService",
"properties": {
"pricingTier": "Standard"
}
}
]
}
}
}
}
}
}
}
},
{
"type": "Microsoft.Authorization/policyDefinitions",
"apiVersion": "2019-09-01",
"name": "[variables('policyDefinitionName-EnableAcrDefender')]",
"properties": {
"displayName": "Azure Defender for container registries is enabled",
"policyType": "Custom",
"mode": "All",
"description": "Azure Defender for container registries provides vulnerability scanning of any images pulled within the last 30 days, pushed to your registry, or imported, and exposes detailed findings per image.",
"metadata": {
"version": "1.0.0",
"category": "Security Center"
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions"
}
]
},
"then": {
"effect": "deployIfNotExists",
"details": {
"type": "Microsoft.Security/pricings",
"name": "ContainerRegistry",
"deploymentScope": "subscription",
"existenceScope": "subscription",
"roleDefinitionIds": [
"[variables('roleId-SecurityAdmin')]"
],
"existenceCondition": {
"field": "Microsoft.Security/pricings/pricingTier",
"equals": "Standard"
},
"deployment": {
"location": "[variables('deploymentResourceRegion')]",
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Security/pricings",
"apiVersion": "2018-06-01",
"name": "ContainerRegistry",
"properties": {
"pricingTier": "Standard"
}
}
]
}
}
}
}
}
}
}
},
{
"type": "Microsoft.Authorization/policyDefinitions",
"apiVersion": "2019-09-01",
"name": "[variables('policyDefinitionName-EnableAkvDefender')]",
"properties": {
"displayName": "Azure Defender for Key Vault is enabled",
"policyType": "Custom",
"mode": "All",
"description": "Azure Defender for Key Vault provides an additional layer of protection and security intelligence by detecting unusual and potentially harmful attempts to access or exploit key vault accounts.",
"metadata": {
"version": "1.0.0",
"category": "Security Center"
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions"
}
]
},
"then": {
"effect": "deployIfNotExists",
"details": {
"type": "Microsoft.Security/pricings",
"name": "KeyVaults",
"deploymentScope": "subscription",
"existenceScope": "subscription",
"roleDefinitionIds": [
"[variables('roleId-SecurityAdmin')]"
],
"existenceCondition": {
"field": "Microsoft.Security/pricings/pricingTier",
"equals": "Standard"
},
"deployment": {
"location": "[variables('deploymentResourceRegion')]",
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Security/pricings",
"apiVersion": "2018-06-01",
"name": "KeyVaults",
"properties": {
"pricingTier": "Standard"
}
}
]
}
}
}
}
}
}
}
},
{
"type": "Microsoft.Authorization/policySetDefinitions",
"apiVersion": "2019-09-01",
"name": "[variables('policySetDefinitionName-EnableDefender')]",
"dependsOn": [
"[subscriptionResourceId('Microsoft.Authorization/policyDefinitions', variables('policyDefinitionName-EnableAksDefender'))]",
"[subscriptionResourceId('Microsoft.Authorization/policyDefinitions', variables('policyDefinitionName-EnableAcrDefender'))]",
"[subscriptionResourceId('Microsoft.Authorization/policyDefinitions', variables('policyDefinitionName-EnableAkvDefender'))]"
],
"properties": {
"displayName": "Enable Azure Defender Standard",
"description": "Ensures Azure Defender is enabled for select resources",
"policyType": "Custom",
"metadata": {
"version": "1.0.0",
"category": "Security Center"
},
"policyDefinitions": [
{
"policyDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/policyDefinitions', variables('policyDefinitionName-EnableAksDefender'))]"
},
{
"policyDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/policyDefinitions', variables('policyDefinitionName-EnableAcrDefender'))]"
},
{
"policyDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/policyDefinitions', variables('policyDefinitionName-EnableAkvDefender'))]"
}
]
}
},
{
"type": "Microsoft.Authorization/policyDefinitions",
"apiVersion": "2019-09-01",
"name": "[variables('policyDefinitionName-DenyPublicAks')]",
"properties": {
"description": "This policy denies the creation of Azure Kubernetes Service non-private clusters",
"displayName": "Public network access on AKS API should be disabled",
"policyType": "Custom",
"mode": "All",
"metadata": {
"version": "1.0.0"
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.ContainerService/managedClusters"
},
{
"field": "Microsoft.ContainerService/managedClusters/apiServerAccessProfile.enablePrivateCluster",
"notequals": "true"
}
]
},
"then": {
"effect": "Deny"
}
}
}
},
{
"type": "Microsoft.Authorization/policyDefinitions",
"apiVersion": "2019-09-01",
"name": "[variables('policyDefinitionName-DenyAagWithoutWaf')]",
"properties": {
"description": "This policy denies the creation of Azure Application Gateway without WAF feature",
"displayName": "WAF SKU must be enabled on Azure Application Gateway",
"policyType": "Custom",
"mode": "All",
"metadata": {
"version": "1.0.0"
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/applicationGateways"
},
{
"field": "Microsoft.Network/applicationGateways/sku.name",
"notequals": "WAF_v2"
}
]
},
"then": {
"effect": "Deny"
}
}
}
},
{
"type": "Microsoft.Authorization/policyDefinitions",
"apiVersion": "2019-09-01",
"name": "[variables('policyDefinitionName-NoPublicIPsForNICsInVnet')]",
"properties": {
"displayName": "Virtual Network should not have NICs attached with public IPs",
"description": "This policy denies network interfaces with public IPs to be attached to the identified Virtual Network. Applied at the subscription level, but expected to be limited to a specific vnet.",
"policyType": "Custom",
"mode": "All",
"metadata": {
"version": "1.0.0",
"category": "Network"
},
"parameters": {
"vnetResourceId": {
"type": "string",
"metadata": {
"displayName": "Virtual Network",
"description": "The Vnet Resource ID that cannot have public IPs",
"strongType": "Microsoft.Network/virtualNetworks"
}
}
},
"policyRule": {
"if": {
"anyOf": [
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/networkInterfaces"
},
{
"field": "Microsoft.Network/networkInterfaces/ipConfigurations[*].publicIpAddress.id",
"like": "*"
},
{
"field": "Microsoft.Network/networkInterfaces/ipConfigurations[*].subnet.id",
"contains": "[[parameters('vnetResourceId')]"
}
]
},
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/virtualMachineScaleSets"
},
{
"field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.networkProfile.networkInterfaceConfigurations[*].ipConfigurations[*].publicIPAddressConfiguration.name",
"like": "*"
},
{
"field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.networkProfile.networkInterfaceConfigurations[*].ipConfigurations[*].subnet.id",
"contains": "[[parameters('vnetResourceId')]"
}
]
}
]
},
"then": {
"effect": "deny"
}
}
}
},
{
"type": "Microsoft.Authorization/policyDefinitions",
"apiVersion": "2019-09-01",
"name": "[variables('policyDefinitionName-NoPublicIPsForVMScaleSets')]",
"properties": {
"displayName": "VM Scale Sets should not have public IPs",
"description": "This policy denies the creation VM Scale Sets which are are configured with any public IPs.",
"policyType": "Custom",
"mode": "All",
"metadata": {
"version": "1.0.0",
"category": "Compute"
},
"parameters": {},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/virtualMachineScaleSets"
},
{
"field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.networkProfile.networkInterfaceConfigurations[*].ipConfigurations[*].publicIPAddressConfiguration.name",
"like": "*"
}
]
},
"then": {
"effect": "deny"
}
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-10-01",
"name": "[concat('Apply-', variables('rgName-Hubs'), '-Policies')]",
"resourceGroup": "[variables('rgName-Hubs')]",
"dependsOn": [
"[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-Hubs'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policyDefinitionId-AllowedResources'), variables('rgName-Hubs'))]",
"comments": "Allowed Resources Policy applied to the hubs RG to only allow select networking and observation resources.",
"properties": {
"displayName": "[trim(take(concat('[', variables('rgName-Hubs'), '] ', reference(variables('policyDefinitionId-AllowedResources'), '2020-09-01').displayName), 125))]",
"description": "List of supported resources for our enterprise hubs resource group",
"scope": "[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-Hubs'))]",
"policyDefinitionId": "[variables('policyDefinitionId-AllowedResources')]",
"parameters": {
"listOfResourceTypesAllowed": {
"value": [
"Microsoft.Insights/diagnosticSettings",
"Microsoft.Insights/workbooks",
"Microsoft.Network/azureFirewalls",
"Microsoft.Network/bastionHosts",
"Microsoft.Network/ipGroups",
"Microsoft.Network/networkSecurityGroups",
"Microsoft.Network/networkSecurityGroups/securityRules",
"Microsoft.Network/publicIpAddresses",
"Microsoft.Network/virtualNetworkGateways",
"Microsoft.Network/virtualNetworks",
"Microsoft.Network/virtualNetworks/subnets",
"Microsoft.Network/virtualNetworks/virtualNetworkPeerings",
"Microsoft.OperationalInsights/workspaces",
"Microsoft.OperationsManagement/solutions",
"Microsoft.Storage/storageAccounts"
]
}
}
}
},
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policyDefinitionId-NetworkWatcherShouldBeEnabled'), variables('rgName-Hubs'))]",
"comments": "Applying the 'Network Watcher Should be Enabled' policy to the Hub resource group.",
"properties": {
"displayName": "[trim(take(concat('[', variables('rgName-Hubs'), '] ', reference(variables('policyDefinitionId-NetworkWatcherShouldBeEnabled'), '2020-09-01').displayName), 125))]",
"scope": "[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-Hubs'))]",
"policyDefinitionId": "[variables('policyDefinitionId-NetworkWatcherShouldBeEnabled')]"
}
}
]
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-10-01",
"name": "[concat('Apply-', variables('rgName-Spokes'), '-Policies')]",
"resourceGroup": "[variables('rgName-Spokes')]",
"dependsOn": [
"[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-Spokes'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policyDefinitionId-AllowedResources'), variables('rgName-Spokes'))]",
"comments": "Allowed Resources Policy applied to the spoke resource group to only allow select networking resources.",
"properties": {
"displayName": "[trim(take(concat('[', variables('rgName-Spokes'), '] ', reference(variables('policyDefinitionId-AllowedResources'), '2020-09-01').displayName), 125))]",
"description": "List of supported resources for our enterprise spokes resource group",
"scope": "[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-Spokes'))]",
"policyDefinitionId": "[variables('policyDefinitionId-AllowedResources')]",
"parameters": {
"listOfResourceTypesAllowed": {
"value": [
"Microsoft.Network/networkSecurityGroups",
"Microsoft.Network/privateDnsZones",
"Microsoft.Network/privateDnsZones/virtualNetworkLinks",
"Microsoft.Network/publicIpAddresses",
"Microsoft.Network/routeTables",
"Microsoft.Network/virtualNetworks",
"Microsoft.Network/virtualNetworks/subnets",
"Microsoft.Network/virtualNetworks/virtualNetworkPeerings"
]
}
}
}
},
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policyDefinitionId-NetworkWatcherShouldBeEnabled'), variables('rgName-Spokes'))]",
"comments": "Applying the 'Network Watcher Should be Enabled' policy to the Spoke resource group.",
"properties": {
"displayName": "[trim(take(concat('[', variables('rgName-Spokes'), '] ', reference(variables('policyDefinitionId-NetworkWatcherShouldBeEnabled'), '2020-09-01').displayName), 125))]",
"scope": "[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-Spokes'))]",
"policyDefinitionId": "[variables('policyDefinitionId-NetworkWatcherShouldBeEnabled')]"
}
}
]
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-10-01",
"name": "[concat('Apply-', variables('rgName-NetworkWatchers'), '-Policies')]",
"resourceGroup": "[variables('rgName-NetworkWatchers')]",
"dependsOn": [
"[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-NetworkWatchers'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policyDefinitionId-AllowedResources'), variables('rgName-NetworkWatchers'))]",
"comments": "Allowed Resources Policy applied to the network watchers resource group to only allow select networking resources.",
"properties": {
"displayName": "[trim(take(concat('[', variables('rgName-NetworkWatchers'), '] ', reference(variables('policyDefinitionId-AllowedResources'), '2020-09-01').displayName), 125))]",
"description": "List of supported resources for our Network Watcher resource group",
"scope": "[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-NetworkWatchers'))]",
"policyDefinitionId": "[variables('policyDefinitionId-AllowedResources')]",
"enforcementMode": "DoNotEnforce", // Since this RG may be under existing policy control in your subscription, adding this policy as audit-only.
"parameters": {
"listOfResourceTypesAllowed": {
"value": [
"Microsoft.Network/networkWatchers",
"Microsoft.Network/networkWatchers/flowLogs"
]
}
}
}
}
]
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-10-01",
"name": "[concat('Apply-', variables('rgName-bu0001A0005'), '-Policies')]",
"resourceGroup": "[variables('rgName-bu0001A0005')]",
"dependsOn": [
"[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-bu0001A0005'))]",
"[subscriptionResourceId('Microsoft.Authorization/policyDefinitions', variables('policyDefinitionName-DenyPublicAks'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policyDefinitionId-AllowedResources'), variables('rgName-bu0001A0005'))]",
"comments": "Allowed Resources Policy applied to the appliction resource group to only allow select resources per workload requirements.",
"properties": {
"displayName": "[trim(take(concat('[', variables('rgName-bu0001A0005'), '] ', reference(variables('policyDefinitionId-AllowedResources'), '2020-09-01').displayName), 125))]",
"description": "List of supported resources for our workload resource group",
"scope": "[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-bu0001A0005'))]",
"policyDefinitionId": "[variables('policyDefinitionId-AllowedResources')]",
"parameters": {
"listOfResourceTypesAllowed": {
"value": [
"Microsoft.Compute/images",
"Microsoft.Compute/virtualMachineScaleSets",
"Microsoft.ContainerRegistry/registries",
"Microsoft.ContainerRegistry/registries/agentPools",
"Microsoft.ContainerRegistry/registries/replications",
"Microsoft.ContainerService/managedClusters",
"Microsoft.Insights/activityLogAlerts",
"Microsoft.Insights/metricAlerts",
"Microsoft.Insights/scheduledQueryRules",
"Microsoft.Insights/workbooks",
"Microsoft.KeyVault/vaults",
"Microsoft.ManagedIdentity/userAssignedIdentities",
"Microsoft.Network/applicationGateways",
"Microsoft.Network/networkInterfaces",
"Microsoft.Network/networkSecurityGroups",
"Microsoft.Network/networkSecurityGroups/securityRules",
"Microsoft.Network/privateDnsZones",
"Microsoft.Network/privateDnsZones/virtualNetworkLinks",
"Microsoft.Network/privateEndpoints",
"Microsoft.OperationalInsights/workspaces",
"Microsoft.OperationsManagement/solutions",
"Microsoft.VirtualMachineImages/imageTemplates"
]
}
}
}
},
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policyDefinitionName-DenyPublicAks'), variables('rgName-bu0001A0005'))]",
"comments": "Deny public AKS clusters policy applied to the appliction resource group.",
"properties": {
"displayName": "[trim(take(concat('[', variables('rgName-bu0001A0005'), '] ', reference(subscriptionResourceId('Microsoft.Authorization/policyDefinitions', variables('policyDefinitionName-DenyPublicAks')), '2020-09-01').displayName), 125))]",
"description": "Only support private AKS clusters, deny any other.",
"scope": "[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-bu0001A0005'))]",
"policyDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/policyDefinitions', variables('policyDefinitionName-DenyPublicAks'))]"
}
},
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policyDefinitionName-NoPublicIPsForVMScaleSets'), variables('rgName-bu0001A0005'))]",
"comments": "Applying the 'No Public IPs on VMSS' policy to the appliction resource group.",
"properties": {
"displayName": "[trim(take(concat('[', variables('rgName-bu0001A0005'), '] ', reference(subscriptionResourceId('Microsoft.Authorization/policyDefinitions', variables('policyDefinitionName-NoPublicIPsForVMScaleSets')), '2020-09-01').displayName), 125))]",
"scope": "[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-bu0001A0005'))]",
"policyDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/policyDefinitions', variables('policyDefinitionName-NoPublicIPsForVMScaleSets'))]"
}
},
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policyDefinitionName-DenyAksWithoutPolicy'), variables('rgName-bu0001A0005'))]",
"comments": "Deny AKS clusters that do not have Azure Policy enabled in the appliction resource group.",
"properties": {
"displayName": "[trim(take(concat('[', variables('rgName-bu0001A0005'), '] ', reference(variables('policyDefinitionId-DenyAksWithoutPolicy'), '2020-09-01').displayName), 125))]",
"description": "Only support AKS clusters with Azure Policy enabled, deny any other.",
"scope": "[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-bu0001A0005'))]",
"policyDefinitionId": "[variables('policyDefinitionId-DenyAksWithoutPolicy')]"
}
},
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policyDefinitionName-DenyAagWithoutWaf'), variables('rgName-bu0001A0005'))]",
"comments": "Deny public AKS clusters policy applied to the appliction resource group.",
"properties": {
"displayName": "[trim(take(concat('[', variables('rgName-bu0001A0005'), '] ', reference(subscriptionResourceId('Microsoft.Authorization/policyDefinitions', variables('policyDefinitionName-DenyAagWithoutWaf')), '2020-09-01').displayName), 125))]",
"description": "Only allow Azure Application Gateway SKU with WAF support.",
"scope": "[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-bu0001A0005'))]",
"policyDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/policyDefinitions', variables('policyDefinitionName-DenyAagWithoutWaf'))]"
}
},
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policyDefinitionName-DenyAksWithoutRbac'), variables('rgName-bu0001A0005'))]",
"comments": "Deny AKS clusters without RBAC policy applied to the appliction resource group.",
"properties": {
"displayName": "[trim(take(concat('[', variables('rgName-bu0001A0005'), '] ', reference(variables('policyDefinitionId-DenyAksWithoutRbac'), '2020-09-01').displayName), 125))]",
"description": "Only allow AKS with RBAC support enabled.",
"scope": "[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-bu0001A0005'))]",
"policyDefinitionId": "[variables('policyDefinitionId-DenyAksWithoutRbac')]"
}
},
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policyDefinitionName-DenyOldAks'), variables('rgName-bu0001A0005'))]",
"comments": "Deny AKS clusters on old version policy applied to the appliction resource group.",
"properties": {
"displayName": "[trim(take(concat('[', variables('rgName-bu0001A0005'), '] ', reference(variables('policyDefinitionId-DenyOldAks'), '2020-09-01').displayName), 125))]",
"description": "Disallow older AKS versions.",
"scope": "[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-bu0001A0005'))]",
"policyDefinitionId": "[variables('policyDefinitionId-DenyOldAks')]"
}
},
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policyDefinitionName-CustomerManagedEncryption'), variables('rgName-bu0001A0005'))]",
"comments": "Applying the 'Customer-Managed Disk Encryption' policy to the resource group.",
"properties": {
"displayName": "[trim(take(concat('[', variables('rgName-bu0001A0005'),'] ', reference(variables('policyDefinitionId-CustomerManagedEncryption'), '2020-09-01').displayName), 125))]",
"scope": "[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-bu0001A0005'))]",
"policyDefinitionId": "[variables('policyDefinitionId-CustomerManagedEncryption')]"
}
},
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policyDefinitionName-EncryptionAtHost'), variables('rgName-bu0001A0005'))]",
"comments": "Applying the 'Encryption at Host' policy to the resource group.",
"properties": {
"displayName": "[trim(take(concat('[', variables('rgName-bu0001A0005'),'] ', reference(variables('policyDefinitionId-EncryptionAtHost'), '2020-09-01').displayName), 125))]",
"scope": "[subscriptionResourceId('Microsoft.Resources/resourceGroups', variables('rgName-bu0001A0005'))]",
"policyDefinitionId": "[variables('policyDefinitionId-EncryptionAtHost')]"
}
}
]
}
}
},
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2020-09-01",
"name": "[guid(variables('policySetDefinitionName-EnableDefender'), subscription().id)]",
"location": "[variables('deploymentResourceRegion')]",
"dependsOn": [
"[subscriptionResourceId('Microsoft.Authorization/policySetDefinitions', variables('policySetDefinitionName-EnableDefender'))]"
],
"identity": {
"type": "SystemAssigned"
},
"comments": "Ensures various Azure Defender services are is enabled.",
"properties": {
"displayName": "[reference(subscriptionResourceId('Microsoft.Authorization/policySetDefinitions', variables('policySetDefinitionName-EnableDefender')), '2020-09-01').displayName]",
"description": "Ensures that Azure Defender for Kuberentes Service, Container Service, and Key Vault are enabled.",
"enforcementMode": "[if(parameters('enforceAzureDefenderAutoDeployPolicies'), 'Default', 'DoNotEnforce')]",
"metadata": {
"version": "1.0.0",
"category": "Security Center"
},
"notScopes": [],
"scope": "[subscription().id]",
"policyDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/policySetDefinitions', variables('policySetDefinitionName-EnableDefender'))]"
}
},
{
"condition": "[parameters('enableAzureDefender')]",
"type": "Microsoft.Security/pricings",
"apiVersion": "2018-06-01",
"name": "KeyVaults",
"comments": "Enable Azure Defender Standard for Key Vault. Requires Owner or Security Admin role.",
"properties": {
"pricingTier": "Standard"
}
},
{
"condition": "[parameters('enableAzureDefender')]",
"type": "Microsoft.Security/pricings",
"apiVersion": "2018-06-01",
"name": "ContainerRegistry",
"comments": "Enable Azure Defender Standard for Container Registry. Requires Owner or Security Admin role.",
"properties": {
"pricingTier": "Standard"
}
},
{
"condition": "[parameters('enableAzureDefender')]",
"type": "Microsoft.Security/pricings",
"apiVersion": "2018-06-01",
"name": "KubernetesService",
"comments": "Enable Azure Defender Standard for Kubernetes Service. Requires Owner or Security Admin role.",
"properties": {
"pricingTier": "Standard"
}
},
{
"condition": "[parameters('enableAzureDefender')]",
"type": "Microsoft.Security/pricings",
"apiVersion": "2018-06-01",
"name": "Arm",
"comments": "Enable Azure Defender Standard for Azure Resource Manager. Requires Owner or Security Admin role.",
"properties": {
"pricingTier": "Standard" // Isn't included in the Azure Policy applications above.
}
},
{
"condition": "[parameters('enableAzureDefender')]",
"type": "Microsoft.Security/pricings",
"apiVersion": "2018-06-01",
"name": "Dns",
"comments": "Enable Azure Defender Standard for Azure DNS. Requires Owner or Security Admin role.",
"properties": {
"pricingTier": "Standard" // Isn't included in the Azure Policy applications above.
}
}
]
}