I’m trying to create a policy that checks all tag names in an array and audits if no allowed values are found. I would like to accomplish this without creating a parameter for each tag name.
Here is the policy to detect 1 or more tag names:
{
"mode": "Indexed",
"policyRule": {
"if": {
"allOf": [
{
"field": "[concat('tags[', parameters('tagName1'), ']')]",
"exists": "false"
},
{
"field": "[concat('tags[', parameters('tagName2'), ']')]",
"exists": "false"
}
]
},
"then": {
"effect": "audit"
}
},
"parameters": {
"tagName1": {
"type": "String",
"metadata": {
"displayName": "Tag Name 1",
"description": "Name of first tag, such as 'environment'"
}
},
"tagName2": {
"type": "String",
"metadata": {
"displayName": "Tag Name 2",
"description": "Name of second tag, such as 'owner'"
}
}
}
}
I’m looking to do the checks in a single array. Just like the Allowed locations policy. So the parameter would be like this:
"parameters": {
"tagNames": {
"type": "Array",
"metadata": {
"description": "List of tag names to audit",
"displayName": "Tag Names"
},
"allowedValues": [
"environment",
"costCenter",
"owner"
]
}
},
Is this possible?
If not, could someone explain why? For my understanding. Thanks
dopbolo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.