tflint-ruleset-aws icon indicating copy to clipboard operation
tflint-ruleset-aws copied to clipboard

Feat => v2:aws_resource_missing_tags errors when tags are provided via default_tags mechanism

Open evairmarinho opened this issue 4 years ago • 6 comments
trafficstars

I have the same needs reported in the issue #117.

In CI/CD scenario i need this tag rule to be followed anyway.

The provider block grants me the tags on all resources, but the risk of having those tags changed is medium/high.

Thanks!

evairmarinho avatar Oct 25 '21 20:10 evairmarinho

I have a question about this need.

This rule was originally added because it was necessary to ensure that it declare tags for each resource. At that time, there was no way to declare tags uniformly for all resources, so this was a valid request.

After that, terraform-provider-aws added a way to declare tags in the provider block, so I'm wondering about the need for this rule. What do you think?

wata727 avatar Oct 31 '21 16:10 wata727

So I would like the default tags not to be changed. Mandatory tags would be defined in .tflint.hcl. I think tflint could have this feature so that people can't get around the necessary tagging rule. If someone wants to change the tag rule, they'll have to change the .tflint.hcl, making it easy to authorize or deny that change.

evairmarinho avatar Oct 31 '21 16:10 evairmarinho

Possible code

providers.tf

provider "aws" {
region = "us-east-1"
default_tags {
    tags = var.default_mandatory_tags
}
}

dev.auto.tfvars

default_mandatory_tags = { Environment = "Test" , CostCenter = "HR"}

.tflint.hcl

rule "aws_resource_missing_tags" {
  enabled = true
  tags = ["Environment", "CostCenter"]
}

evairmarinho avatar Oct 31 '21 16:10 evairmarinho

@wata727, if you think that what I need would be another rule, that's fine! I can open a new issue, explaining better.

evairmarinho avatar Oct 31 '21 17:10 evairmarinho

Ah, okay. It makes sense. I thought that if the default_tags were declared statically, it would duplicate the declaration in .tflint.hcl, but I understand that why you want if it's declared with complex evaluation.

wata727 avatar Nov 02 '21 17:11 wata727

I would like this too. I think it would be good to create a new rule aws_provider_missing_default_tags

glenthomas avatar Jul 01 '22 16:07 glenthomas