Closed sunnygoel87 closed 1 year ago
@antonbabenko - Could you please help me resolve this? Thanks a lot
I think the path to .tflint.hcl
is incorrect because now it expects such config in each directory. Try to specify __GIT_WORKING_DIR__/.tflint.hcl
as described here.
@antonbabenko - Thanks a lot for the prompt response. Moving .tflint.hcl
file at the root level and passing the arg in .pre-commit-config.yaml
file as you suggested fixed the issue.
Describe the bug
I'm using
terraform_tflint
hook from this repo. in our project to identify the potential possible errors (before they occur) and ensure that Terraform code complies with best practices. I've specified the terraform version and aws provider version inmain.tf
file at root level but it seems,tflint
expects us to specify the terraform block and aws provider inmain.tf
file under each module.How can we reproduce it?
Leverage
.pre-commit-config.yaml
file as given below and.tflint.hcl
file as shown below. Afterwards, have aninfrastructure
folder in your application, create a couple of modules and don't specify the terraform version and aws provider version inmain.tf
file under those modules. Runpre-commit run -a
command locally in IDE and then you should be able to see the error message I pasted below..tflint.hcl
:file content
```bash plugin "terraform" { enabled = true preset= "recommended" } plugin "aws" { enabled = true version = "0.23.1" source = "github.com/terraform-linters/tflint-ruleset-aws" } rule "terraform_required_version" { enabled = false } rule "terraform_required_providers" { enabled = false } ```Environment information
OS: MacOS
uname -a
and/orsysteminfo | Select-String "^OS"
output:.pre-commit-config.yaml
:file content
```bash repos: - repo: https://github.com/antonbabenko/pre-commit-terraform rev: v1.80.0 # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases hooks: - id: terraform_tflint args: - --args=--config=.tflint.hcl - --args=--module ```