-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Resource Invalid Tags rule #639
base: master
Are you sure you want to change the base?
Add Resource Invalid Tags rule #639
Conversation
eda7fa7
to
526d22f
Compare
526d22f
to
e39d0a0
Compare
Intuitively, this is a superset of the aws_resource_missing_tags rule, so it seems to make sense to extend it. What do you think? |
@wata727 what are you referring to? |
If nothing else I would agree that it doesn't make sense to have one rule to require tag keys and a separate one for tag values. Seems like they should be consolidated into rule "aws_resource_tags" {
required = ["Foo"]
values = {
Foo = ["Bar"]
Baz = ["Qux"] # optional
}
} |
If we're happy to implement a single rule to provide both features for tags I would extend upon @bendrucker's comment above and propose the following: rule "aws_resource_tags" {
rules = {
Foo = { values: ["Bar"], required: true },
Baz = { values: ["Qux"] }, # not required by default
}
} The AWS Docs specify some hard restrictions on the tags which could be configured with an additionally adjusted DSL: rule "aws_resource_tags" {
tags_max_count = 10, # default value from doc
key_max_length = 32, # default value from doc
value_max_length = 128, # default value from doc
character_allow_list = ["+", "-", "="], # default value from doc
rules = {
Foo = { allowed_prefixes = ["foo:"] }, # support per-tag value prefix matching
Baz = { allowed_characters = ["+", "-"] }, # support per-tag restriction of valid characters
Xar = { max_length = 3 }, # support per-tag character length restriction
}
} NOTE: I am not suggesting the future implementation in this PR, just the former to meet the existing and proposed functionality:
|
I don't expect we'll ever pursue all these knobs around allowed characters, length, etc. We don't need to create space for that at the expense of straightforward cases. It's an option, but we shouldn't be creating an awkward API with the expectation of extending it substantially. A good practical goal here would be to support an |
Add
aws_resource_invalid_tags
rule to support enforcing of specific values for the given tag keys.