Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 27363b7

Browse files
Support Defender Plan for Cosmos DB (Azure#200)
Add CosmosDB Defender Plan and custom policy to deploy Defender Plan for Cosmos DB
1 parent 81eccd1 commit 27363b7

File tree

6 files changed

+118
-1
lines changed

6 files changed

+118
-1
lines changed

azresources/security-center/asc.bicep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ var azureDefenderServices = [
5050
'Arm'
5151
'AppServices'
5252
'Containers'
53+
'CosmosDbs'
5354
'Dns'
5455
'KeyVaults'
5556
'OpenSourceRelationalDatabases'
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "Configure Microsoft Defender for Cosmos DB to be enabled",
3+
"mode": "all"
4+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"pricingTier": {
3+
"type": "string",
4+
"metadata": {
5+
"displayName": "Azure Defender pricing tier",
6+
"description": "Azure Defender pricing tier"
7+
},
8+
"allowedValues": [
9+
"Standard",
10+
"Free"
11+
],
12+
"defaultValue": "Standard"
13+
},
14+
"effect": {
15+
"type": "string",
16+
"metadata": {
17+
"displayName": "Effect",
18+
"description": "Enable or disable the execution of the policy"
19+
},
20+
"allowedValues": [
21+
"DeployIfNotExists",
22+
"Disabled"
23+
],
24+
"defaultValue": "DeployIfNotExists"
25+
}
26+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"if": {
3+
"allOf": [
4+
{
5+
"field": "type",
6+
"equals": "Microsoft.Resources/subscriptions"
7+
}
8+
]
9+
},
10+
"then": {
11+
"effect": "[parameters('effect')]",
12+
"details": {
13+
"type": "Microsoft.Security/pricings",
14+
"name": "CosmosDbs",
15+
"deploymentScope": "Subscription",
16+
"existenceScope": "Subscription",
17+
"roleDefinitionIds": [
18+
"/providers/Microsoft.Authorization/roleDefinitions/fb1c8493-542b-48eb-b624-b4c8fea62acd"
19+
],
20+
"existenceCondition": {
21+
"allOf": [
22+
{
23+
"field": "Microsoft.Security/pricings/pricingTier",
24+
"equals": "[parameters('pricingTier')]"
25+
},
26+
{
27+
"field": "type",
28+
"equals": "Microsoft.Security/pricings"
29+
}
30+
]
31+
},
32+
"deployment": {
33+
"location": "canadacentral",
34+
"properties": {
35+
"mode": "incremental",
36+
"parameters": {
37+
"pricingTier": {
38+
"value": "[parameters('pricingTier')]"
39+
}
40+
},
41+
"template": {
42+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
43+
"contentVersion": "1.0.0.0",
44+
"parameters": {
45+
"pricingTier": {
46+
"type": "string",
47+
"metadata": {
48+
"description": "Azure Defender pricing tier"
49+
}
50+
}
51+
},
52+
"variables": {},
53+
"resources": [
54+
{
55+
"type": "Microsoft.Security/pricings",
56+
"apiVersion": "2018-06-01",
57+
"name": "CosmosDbs",
58+
"properties": {
59+
"pricingTier": "[parameters('pricingTier')]"
60+
}
61+
}
62+
],
63+
"outputs": {}
64+
}
65+
}
66+
}
67+
}
68+
}
69+
}

policy/custom/definitions/policyset/DefenderForCloud.bicep

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
targetScope = 'managementGroup'
1111

12+
@description('Management Group scope for the policy definition.')
13+
param policyDefinitionManagementGroupId string
14+
15+
var customPolicyDefinitionMgScope = tenantResourceId('Microsoft.Management/managementGroups', policyDefinitionManagementGroupId)
16+
1217
resource ascAzureDefender 'Microsoft.Authorization/policySetDefinitions@2020-03-01' = {
1318
name: 'custom-enable-azure-defender'
1419
properties: {
@@ -164,6 +169,14 @@ resource ascAzureDefender 'Microsoft.Authorization/policySetDefinitions@2020-03-
164169
policyDefinitionReferenceId: toLower(replace('Configure Microsoft Defender for Containers to be enabled', ' ', '-'))
165170
parameters: {}
166171
}
172+
{
173+
groupNames: [
174+
'EXTRA'
175+
]
176+
policyDefinitionId: extensionResourceId(customPolicyDefinitionMgScope, 'Microsoft.Authorization/policyDefinitions', 'DefenderForCloud-Deploy-DefenderPlan-CosmosDB')
177+
policyDefinitionReferenceId: toLower(replace('Configure Microsoft Defender for Cosmos DB to be enabled', ' ', '-'))
178+
parameters: {}
179+
}
167180
]
168181
}
169182
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
33
"contentVersion": "1.0.0.0",
4-
"parameters": {}
4+
"parameters": {
5+
"policyDefinitionManagementGroupId": {
6+
"value": "{{var-topLevelManagementGroupName}}"
7+
}
8+
}
59
}

0 commit comments

Comments
 (0)