Skip to content

Commit

Permalink
Merge pull request #188 from ElYusubov/development
Browse files Browse the repository at this point in the history
Minor updates to tag policyto manage RGs
  • Loading branch information
ElYusubov authored Nov 3, 2024
2 parents c6dd19e + faeaa0b commit 31f8515
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// audit-resourcegroup-tag-and-its-value-format.bicep

// Set the scope of the deployment
targetScope = 'subscription'

// Set variables for the policy definition
var policyName = 'audit-resource-group-tag-and-value-format-pd'
var policyDisplayName = 'Audit a tag and its value format on resource groups'
var policyDescription = 'Audits existence of a tag and its value format. Does not apply to individual resources.'

// Create the policy definition
resource policy 'Microsoft.Authorization/policyDefinitions@2020-09-01' = {
name: policyName
properties: {
Expand Down Expand Up @@ -31,7 +36,6 @@ resource policy 'Microsoft.Authorization/policyDefinitions@2020-09-01' = {
}
}
}

policyRule: {
if: {
allOf: [
Expand All @@ -51,3 +55,21 @@ resource policy 'Microsoft.Authorization/policyDefinitions@2020-09-01' = {
}
}
}

// Create the policy assignment
resource policyAssignment 'Microsoft.Authorization/policyAssignments@2020-09-01' = {
name: '${policyName}-assignment'
properties: {
policyDefinitionId: policy.id
displayName: policyDisplayName
description: policyDescription
parameters: {
tagName: {
value: 'Environment'
}
tagPattern: {
value: 'Test'
}
}
}
}

0 comments on commit 31f8515

Please sign in to comment.