How to check naming convention for tag keys
How can I validate that tag keys match a particular naming convention
I'm just starting out with terraform-compliance and it's awesome. Thank you for this project :tada:
But I'm struggling with defining naming conventions for resource tag keys. I would like to validate, that each tag defined matches a certain regular expression.
I have the following Scenario defined right now:
Scenario: Ensure that tag keyss are all lowercase with hyphens separating words and colons separating namespaces
Given I have resource that supports tags defined
Then it must contain tags
And its value must match the "^(([a-z\d-]+[^-:]:)*[^:-]+)|Name$" regex
This also matches the tags values, so for example a tag definition of
"tags":{
"Name":"application-environment-foo",
"mycompany:owner":"[email protected]",
"mycompany:project-id":"foo"
}
is rejected, because the regex is also applied to the values of each tag key.
Is there a way to only match the regex on the tags keys?
This example shows how to explicitly define acceptable tag names... struggling to use it with a regex https://terraform-compliance.com/pages/Examples/tags_related.html#ensure-that-specific-tags-are-defined