-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpolicyAssignment.bicep
38 lines (35 loc) · 1.2 KB
/
policyAssignment.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
targetScope = 'subscription'
// PARAMETERS
param bicepExampleInitiativeId string
param assignmentIdentityLocation string
param assignmentEnforcementMode string
// RESOURCES
resource bicepExampleAssignment 'Microsoft.Authorization/policyAssignments@2020-09-01' = {
name: 'bicepExampleAssignment'
location: assignmentIdentityLocation
identity: {
type: 'SystemAssigned'
}
properties: {
displayName: 'Bicep Example Assignment'
description: 'Bicep Example Assignment'
enforcementMode: assignmentEnforcementMode
metadata: {
source: 'Bicep'
version: '0.1.0'
}
policyDefinitionId: bicepExampleInitiativeId
nonComplianceMessages: [
{
message: 'Resource is not compliant with a DeployIfNotExists policy'
}
]
}
}
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
name: guid(bicepExampleAssignment.name, bicepExampleAssignment.type, subscription().subscriptionId)
properties: {
principalId: bicepExampleAssignment.identity.principalId
roleDefinitionId: '/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c' // contributor RBAC role for deployIfNotExists effect
}
}