when the policy run it can check the error in “environment” as below
Print messages:
azurerm_windows_virtual_machine.windowsvm has tags.environment with value: "D3@$v"
that is not in the allowed list: ^[a-zA-Z0-9]+$
./tag-regex.sentinel:15:1 - Rule "main"
Value:
false
The problem is, i also want to check the “tags.backup” as well. But don’t know where to add it within the code to check for! Since i’ve tried so many ways already !
please help!
But, i need to add the “tags.backup” but there is no option as: “tags.environment | tags.backup” or “tags.environment|backup” to do the check.
that is only check if the tags has “environment” and “backup”
if it so, the policy will pass. Otherwise, the policy will be failed!
Not any mention about the tags.environment or tags. backup value that can be checked with regex
("^[a-zA-Z0-9]+$")
my question is how to check the “tags.environment and tags.backup” value with the regex
("^[a-zA-Z0-9]+$")
because i can only run a check that is tags.environment or tags.backup with regex only. Not with both!
here is the tags sample:
i can find out the solution for it!
need to double the block :
violatingAzureResources = plan.filter_attribute_not_in_list(
allAzureResourcesWithStandardTags,
“tags.environment” ,
“[1]+$”,
true,
)
another is point to “tags.backup”
and of course, thanks for your recommendation to use “plan.filter_attribute_does_not_match_regex”
without it, i can not make it work properly!
thank you again!