-
Notifications
You must be signed in to change notification settings - Fork 5
/
eventgrid.bicep
55 lines (52 loc) · 1.39 KB
/
eventgrid.bicep
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
@secure()
param uri string
param topicName string
param location string
var policyDefinitionId = '/providers/Microsoft.Authorization/policyDefinitions/ebb67efd-3c46-49b0-adfe-5599eb944998'
resource softwarepol 'Microsoft.Authorization/policyAssignments@2020-09-01' = {
name: guid(topicName)
location: location
properties: {
policyDefinitionId: policyDefinitionId
displayName: 'Audit windows virtual machines without PowerShell installed'
parameters: {
installedApplication: {
value: 'PowerShell 7-x64'
}
}
}
}
resource esub 'Microsoft.EventGrid/systemTopics/eventSubscriptions@2020-10-15-preview' = {
name: '${topicName}/PolicyChanges'
properties: {
destination: {
endpointType: 'WebHook'
properties: {
endpointUrl: uri
}
}
eventDeliverySchema: 'EventGridSchema'
filter: {
includedEventTypes: [
'Microsoft.PolicyInsights.PolicyStateChanged'
'Microsoft.PolicyInsights.PolicyStateCreated'
]
advancedFilters: [
{
operatorType: 'StringContains'
key: 'data.policyAssignmentId'
values: [
reference(softwarepol.name, '2020-09-01', 'full').resourceId
]
}
{
operatorType: 'StringBeginsWith'
key: 'data.complianceState'
values: [
'NonCompliant'
]
}
]
}
}
}