Skip to content
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

for_each/count meta-arguments are not overridden correctly #2151

Open
1 of 3 tasks
wata727 opened this issue Nov 4, 2024 · 0 comments
Open
1 of 3 tasks

for_each/count meta-arguments are not overridden correctly #2151

wata727 opened this issue Nov 4, 2024 · 0 comments
Labels

Comments

@wata727
Copy link
Member

wata727 commented Nov 4, 2024

Summary

See also #2114

Many of the overriding issues in TFLint have been fixed in #2124, but there are still issues with overriding meta arguments. In Terraform, meta arguments are overridden and then resources are expanded, but in TFLint, they are overridden after expansion, so if the original and override meta arguments are different, the override expansion cannot be followed.

Command

tflint

Terraform Configuration

# main.tf
resource "aws_instance" "main" {
  instance_type = "t2.micro"
}

# main_override.tf
resource "aws_instance" "main" {
  count = 2

  instance_type = "t${count.index + 1}.invalid"
}

TFLint Configuration

plugin "terraform" {
  enabled = false
}

plugin "aws" {
  enabled = true
  version = "0.34.0"
  source  = "github.com/terraform-linters/tflint-ruleset-aws"
}

Output

1 issue(s) found:

Error: "t2.invalid" is an invalid value as instance_type (aws_instance_invalid_type)

  on main_override.tf line 4:
   4:   instance_type = "t${count.index + 1}.invalid"

Issues should be reported for two resources, but only one is reported.

TFLint Version

0.53.0

Terraform Version

1.9.8

Operating System

  • Linux
  • macOS
  • Windows
@wata727 wata727 added the bug label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant