-
Notifications
You must be signed in to change notification settings - Fork 72
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
aws_resource_missing_tags appears broken #48
Comments
Hmmm, I couldn't reproduce the problem. Maybe I think the cause is Autoscaling group. Would you please share the minimum code that would cause the problem? |
The code for the asg is pretty boring since it's all just using variables. Looks like the way my colleague split the tags out is a little weird. Could be the problem, but both ways are documented as valid (multiple tag blocks and tags variable). It looks like I can reproduce the one error:
Example: locals {
tags = merge(
{
Owner = "unspecified"
Environment = "unspecified"
},
var.tags,
{
Type = format("broker/rabbitmq")
Terraform = "true"
}
)
tags_asg_format = null_resource.tags_as_list_of_maps.*.triggers
}
variable "tags" {
type = map(string)
default = {}
}
resource "null_resource" "tags_as_list_of_maps" {
count = length(keys(local.tags))
triggers = {
"key" = keys(local.tags)[count.index]
"value" = values(local.tags)[count.index]
"propagate_at_launch" = "true"
}
}
resource "aws_autoscaling_group" "this" {
name_prefix = local.asg_name
launch_configuration = aws_launch_configuration.this.*.name[0]
vpc_zone_identifier = var.subnets
max_size = var.asg_max_size
min_size = var.asg_min_size
desired_capacity = var.asg_desired_capacity
load_balancers = var.load_balancers
health_check_grace_period = var.health_check_grace_period
health_check_type = var.health_check_type
min_elb_capacity = var.min_elb_capacity
wait_for_elb_capacity = var.wait_for_elb_capacity
target_group_arns = [aws_lb_target_group.this.arn, aws_lb_target_group.this_tls.arn]
default_cooldown = var.default_cooldown
force_delete = var.force_delete
termination_policies = var.termination_policies
suspended_processes = var.suspended_processes
placement_group = var.placement_group
enabled_metrics = var.enabled_metrics
metrics_granularity = var.metrics_granularity
wait_for_capacity_timeout = var.wait_for_capacity_timeout
protect_from_scale_in = var.protect_from_scale_in
tags = local.tags_asg_format
} |
If I modify the asg code to use "tag" this seems to fail with the same error as well: resource "aws_autoscaling_group" "this" {
name_prefix = local.asg_name
launch_configuration = aws_launch_configuration.this.*.name[0]
vpc_zone_identifier = var.subnets
max_size = var.asg_max_size
min_size = var.asg_min_size
desired_capacity = var.asg_desired_capacity
load_balancers = var.load_balancers
health_check_grace_period = var.health_check_grace_period
health_check_type = var.health_check_type
min_elb_capacity = var.min_elb_capacity
wait_for_elb_capacity = var.wait_for_elb_capacity
target_group_arns = [aws_lb_target_group.this.arn, aws_lb_target_group.this_tls.arn]
default_cooldown = var.default_cooldown
force_delete = var.force_delete
termination_policies = var.termination_policies
suspended_processes = var.suspended_processes
placement_group = var.placement_group
enabled_metrics = var.enabled_metrics
metrics_granularity = var.metrics_granularity
wait_for_capacity_timeout = var.wait_for_capacity_timeout
protect_from_scale_in = var.protect_from_scale_in
// tags = local.tags_asg_format
dynamic "tag" {
for_each = local.tags
content {
key = tag.key
value = tag.value
propagate_at_launch = "true"
}
}
} |
Here's the debug log. I also tried statically assigning the tags variable and tag blocks and the error still occurred.
|
So here's the static blocks I tried: tag {
key = "Name"
value = "asdf"
propagate_at_launch = "true"
} tags = [
{
key = "Name"
value = "asdf"
propogate_at_launch = "true"
}
] For these I had simplified my tflint config to only specify this: rule "aws_resource_missing_tags" {
enabled = true
// tags = ["Environment", "Owner", "Terraform", "Name", "Type"]
tags = ["Name"]
exclude = []
} |
Thank you for sharing examples. Understood. This issue is caused by the cty-based expression evaluation. tflint-ruleset-aws/rules/aws_resource_missing_tags.go Lines 229 to 230 in 3ab728b
Previously, it works but the plugin system doesn't support mapping evaluation results to structs. I will consider how to fix it. |
I noticed there was an existing ticket about this rule, but I don't think they're related (I could be wrong).
After updating to tflint
v0.23.1
and installing this module atv0.1.2
I am now seeing a large number of errors coming out of theaws_resource_missing_tags
rule.I have a rule created like this:
We are configuring tags using a merge operation with a variable that gets merged in:
This appears to fail this check with the following types of errors:
Maybe I'm doing something wrong, but I hope someone can either point me in the right direction or maybe I found a bug?
The text was updated successfully, but these errors were encountered: