pre-commit-terraform
                                
                                 pre-commit-terraform copied to clipboard
                                
                                    pre-commit-terraform copied to clipboard
                            
                            
                            
                        Support tflint modules with differing module dependencies
What problem are you facing?
In my configuration, I have a number of different modules in the same repo but each module has differing dependencies (either local or published). At present, I'm linting by running cd {dir} && terraform get && tflint for each module directory to ensure all dependencies are available and installed. When trying to use the terraform_tflint hook, it fails for modules with dependencies.
How could pre-commit-terraform help solve your problem?
Have the ability to automatically invoke terraform get per-directory when running the tflint hook, either by default or with a flag. Whilst terraform get is a noop when nothing needs to be done, it still takes time to be invoked so an opt-in hook flag may be the better option.
Happy to help craft a PR if this is something that could be incorporated.
You can do next as a workaround (because t init took more time than t get)
- id: terraform_validate
  args:
    - --hook-config=--retry-once-with-cleanup=true
    # - --tf-init-args=-upgrade
- id: terraform_tflint
  args:
    - --args=--config=__GIT_WORKING_DIR__/.tflint.hcl
Also, because tflint and t validate can't fully replace each other, it can be a solution, not a temporary workaround
Thanks @MaxymVlasov - I appreciate the workaround. It is fairly slow to re-init Terraform each tune, as you say, especially when multiple modules and configurations are changing in a given commit, but workable for small changes.
Side note:  terraform_providers_lock could use t get too, rather depend on terraform_validate
What should be done:
- 
create by analog common::terraform_getfunctionhttps://github.com/antonbabenko/pre-commit-terraform/blob/ae5cbe0342617310b0491146d51573f2f4c93705/hooks/_common.sh#L316 
- 
Include it in terraform_tflintby analogue howcommon::terraform_initused interraform_validatehook
- 
(Optional) Add it to terraform_providers_lockhook too
Not sure if anyone is aware, but TFLint 0.50.0 has some specific changes relating to the handling of modules and has marked that change as a BC (but is documented more like a deprecation notice).
https://github.com/terraform-linters/tflint/releases/tag/v0.50.0
Hopefully, the work undertaken there can be integrated/supported by pre-commit-terraform.