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

tflint - No such file or directory #80

Closed
vitali-s opened this issue Dec 21, 2019 · 4 comments
Closed

tflint - No such file or directory #80

vitali-s opened this issue Dec 21, 2019 · 4 comments

Comments

@vitali-s
Copy link

Hello, for my typical terraform + terragrunt repo with following .tflint.hcl configuration:

config {
  module     = true
  deep_check = false
  force      = false
}

And following hook configuration:

  - repo: git://github.com/antonbabenko/pre-commit-terraform
    rev: v1.21.0
    hooks:
      - id: terraform_fmt
      - id: terraform_validate
      - id: terraform_tflint
        args: [' --config .tflint.hcl']
      - id: terragrunt_fmt

Getting following errors:

/Users/user/.cache/pre-commit/repo31phc1no/terraform_tflint.sh: line 42: pushd --config .tflint.hcl modules/dynamodb-table/dynamodb-table.tf modules/dynamodb-table/dynamodb-table-outputs.tf modules/s3-state-bucket: No such file or directory
@grzegorzlisowski
Copy link

grzegorzlisowski commented Dec 29, 2019

(Copy of the comment I have put in other issue).

To make it work you need two things:

  1. Following PR merged into master and new version released (or have your own fork): tflint: iterate over files #77

  2. One of the latest PRs merged to the mainline changed the way of passing arguments to the tflint.

I have no clue how this is working for anyone: https://github.com/antonbabenko/pre-commit-terraform#notes-about-terraform_tflint-hooks

  - id: terraform_tflint
    args: ['--deep']

Maybe I'm missing something important. Per the code in the the script and according to the way how pre-commit passes arguments to the scripts (https://pre-commit.com/#passing-arguments-to-hooks), the only solution which I see is this:

  - id: terraform_tflint
    args: ['--args', '--config=.tflint.hcl']

@vitali-s
Copy link
Author

When passing config:

args: ['--args', '--config=.tflint.hcl']

Getting another issue:

dirname: illegal option -- -
usage: dirname path

@grzegorzlisowski
Copy link

grzegorzlisowski commented Dec 31, 2019

Look at point #1 in my comment. This PR must be merged to master: #77
OR you could fork this repo and apply the patch on your own.

@antonbabenko
Copy link
Owner

v1.25.0 of pre-commit-terraform has been just released after #77 was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants