Skip to content

Commit

Permalink
Refactor mandatory tags definition in Audit-Tags-Mandatory policies f…
Browse files Browse the repository at this point in the history
…or improved clarity and consistency
  • Loading branch information
Springstone committed Nov 18, 2024
1 parent f4ad58d commit b4eb1cc
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,52 +32,51 @@
"defaultValue": "Audit"
},
"mandatoryTags": {
"type": "Array",
"metadata": {
"displayName": "Array of mandatory tags",
"description": "Array of mandatory tags that must be present on the resource group. The array should contain semicolon separated list of the tag names."
},
"defaultValue": []
"type": "Array",
"metadata": {
"displayName": "Array of mandatory tags",
"description": "Array of mandatory tags that must be present on the resource group. The array should contain semicolon separated list of the tag names."
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions/resourceGroups"
},
{
"anyOf": [
{
"not": {
"count": {
"value": "[[parameters('mandatoryTags')]",
"name": "tagcount",
"where": {
"field": "tags",
"containsKey": "[[current('tagcount')]"
}
},
"equals": "[[length(parameters('mandatoryTags'))]"
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions/resourceGroups"
},
{
"anyOf": [
{
"not": {
"count": {
"value": "[[parameters('mandatoryTags')]",
"name": "tagcount",
"where": {
"field": "tags",
"containsKey": "[[current('tagcount')]"
}
},
"equals": "[[length(parameters('mandatoryTags'))]"
}
},
{
"not": {
"count": {
"value": "[[parameters('mandatoryTags')]",
"name": "tagnullcount",
"where": {
"value": "[[resourceGroup().tags[current('tagnullcount')]]",
"notMatch": ""
}
},
"equals": "[[length(parameters('mandatoryTags'))]"
}
}
},
{
"not": {
"count": {
"value": "[[parameters('mandatoryTags')]",
"name": "tagnullcount",
"where": {
"value": "[[resourceGroup().tags[current('tagnullcount')]]",
"notMatch": ""
}
},
"equals": "[[length(parameters('mandatoryTags'))]"
}
}
]
}
]
]
}
]
},
"then": {
"effect": "[[parameters('effect')]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,43 @@
"defaultValue": "Audit"
},
"mandatoryTags": {
"type": "Array",
"metadata": {
"displayName": "Array of mandatory tags",
"description": "Array of mandatory tags that must be present on the resource group. The array should contain semicolon separated list of the tag names."
},
"defaultValue": []
"type": "Array",
"metadata": {
"displayName": "Array of mandatory tags",
"description": "Array of mandatory tags that must be present on the resource group. The array should contain semicolon separated list of the tag names."
}
}
},
"policyRule": {
"if": {
"anyOf": [
{
"not": {
"count": {
"value": "[[parameters('mandatoryTags')]",
"name": "tagcount",
"where": {
"field": "tags",
"containsKey": "[[current('tagcount')]"
}
},
"equals": "[[length(parameters('mandatoryTags'))]"
}
},
{
"not": {
"count": {
"value": "[[parameters('mandatoryTags')]",
"name": "tagnullcount",
"where": {
"value": "[[resourceGroup().tags[current('tagnullcount')]]",
"notMatch": ""
}
},
"equals": "[[length(parameters('mandatoryTags'))]"
}
{
"not": {
"count": {
"value": "[[parameters('mandatoryTags')]",
"name": "tagcount",
"where": {
"field": "tags",
"containsKey": "[[current('tagcount')]"
}
},
"equals": "[[length(parameters('mandatoryTags'))]"
}
},
{
"not": {
"count": {
"value": "[[parameters('mandatoryTags')]",
"name": "tagnullcount",
"where": {
"value": "[[resourceGroup().tags[current('tagnullcount')]]",
"notMatch": ""
}
},
"equals": "[[length(parameters('mandatoryTags'))]"
}
]
}
]
},
"then": {
"effect": "[[parameters('effect')]"
Expand Down

0 comments on commit b4eb1cc

Please sign in to comment.