From 5efc9929782d9371ed20f2a4cca81edf32a77b3f Mon Sep 17 00:00:00 2001 From: Elkhan Date: Sat, 2 Nov 2024 23:46:22 -0400 Subject: [PATCH] Minor updates to tag policyto manage RGs --- ...sourcegroup-tag-and-its-value-format.bicep | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tagging-policies/audit-resourcegroup-tag-and-its-value-format.bicep b/tagging-policies/audit-resourcegroup-tag-and-its-value-format.bicep index 611a50c..dddc1c1 100644 --- a/tagging-policies/audit-resourcegroup-tag-and-its-value-format.bicep +++ b/tagging-policies/audit-resourcegroup-tag-and-its-value-format.bicep @@ -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: { @@ -31,7 +36,6 @@ resource policy 'Microsoft.Authorization/policyDefinitions@2020-09-01' = { } } } - policyRule: { if: { allOf: [ @@ -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' + } + } + } +}