tflint-ruleset-terraform
tflint-ruleset-terraform copied to clipboard
No source specified for `terraform_required_version` warning in a local module
Summary
It is not clear from the output of tflint which modules are missing a required_version for terraform. The warning just says on line 0: (source code not available) which is not helpful for finding the issue.
Command
tflint --recursive
Terraform Configuration
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.49"
}
}
}
data "aws_availability_zones" "available" {}
TFLint Configuration
tflint {
required_version = "~> 0.51"
}
plugin "terraform" {
enabled = true
preset = "recommended"
}
plugin "aws" {
enabled = true
version = "0.31.0"
source = "github.com/terraform-linters/tflint-ruleset-aws"
}
Output
Warning: terraform "required_version" attribute is required (terraform_required_version)
on line 0:
(source code not available)
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.7.0/docs/rules/terraform_required_version.md
TFLint Version
0.51.1
Terraform Version
No response
Operating System
- [ ] Linux
- [X] macOS
- [ ] Windows
I agree that there is room for improvement in the current output, but be aware that this is a rule that reports "missing" required declarations, so you may not always get a valid range. For example, we may also need to report this issue for empty directories.
See also https://github.com/terraform-linters/tflint/issues/1790
Yeah, thank you. That makes sense. I get why we'd see (source code not available) for a "missing" report, but an indication of the file or directory would at least make the warning actionable.