Describe the bug
Because the terragrunt-generated files (providers.tf, terraform.tf etc.) are gitignored, if deployments haven't been ran locally before committing terraform file changes, the pre-commit terraform checks might fail and give output like this:
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -
[INFO] Checking merge-conflict files only.
Flake8...............................................(no files to check)Skipped
Fix End of Files.........................................................Passed
black................................................(no files to check)Skipped
Terraform fmt............................................................Passed
Terraform validate.......................................................Failed
- hook id: terraform_validate
- exit code: 1
[0m[31m'terraform init' failed, 'terraform validate' skipped: infrastructure/transform[0m
[0m[1mInitializing provider plugins...[0m
- Reusing previous version of hashicorp/time from the dependency lock file
- Reusing previous version of hashicorp/null from the dependency lock file
- Reusing previous version of hashicorp/random from the dependency lock file
- Reusing previous version of hashicorp/azurerm from the dependency lock file
- Reusing previous version of hashicorp/azuread from the dependency lock file
- Finding latest version of hashicorp/databricks...
- Using previously-installed hashicorp/azurerm v3.47.0
- Using previously-installed hashicorp/azuread v2.35.0
- Using previously-installed hashicorp/time v0.9.1
- Using previously-installed hashicorp/null v3.2.1
- Using previously-installed hashicorp/random v3.4.3
[31m[31m╷[0m[0m
[31m│[0m [0m[1m[31mError: [0m[0m[1mFailed to query available provider packages[0m
[31m│[0m [0m
[31m│[0m [0m[0mCould not retrieve the list of available versions for provider
[31m│[0m [0mhashicorp/databricks: provider registry registry.terraform.io does not have
[31m│[0m [0ma provider named registry.terraform.io/hashicorp/databricks
[31m│[0m [0m
[31m│[0m [0mAll modules should specify their required_providers so that external
[31m│[0m [0mconsumers will get the correct providers when using a module. To see which
[31m│[0m [0mmodules are currently depending on hashicorp/databricks, run the following
[31m│[0m [0mcommand:
[31m│[0m [0m terraform providers
[31m╵[0m[0m
[0m[0m
Terragrunt fmt.......................................(no files to check)Skipped
Terraform validate with tflint...........................................Failed
- hook id: terraform_tflint
- exit code: 2
[0m[32mCommand 'tflint --init' successfully done:[0m
Plugin `terraform` is already installed
Plugin `azurerm` is already installed
[0m[33mTFLint in infrastructure/transform/:[0m
7 issue(s) found:
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.2.2/docs/rules/terraform_required_version.md
Warning: Missing version constraint for provider "time" in "required_providers" (terraform_required_providers)
on databricks.tf line 38:
38: resource "time_sleep" "wait_for_databricks_network" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.2.2/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "databricks" in "required_providers" (terraform_required_providers)
on secrets.tf line 68:
68: resource "databricks_secret" "flowehr_databricks_sql_database" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.2.2/docs/rules/terraform_required_providers.md
shellcheck...........................................(no files to check)Skipped
yamllint.............................................(no files to check)Skipped
Ensure copyright and license headers are present.........................Passed
We ideally need to be able to tell the pre-commit hooks to run a terragrunt init before the terraform checks. We do this currently in the pr checks workflow but that only prevents this in GH, not locally.
Describe the bug Because the terragrunt-generated files (
providers.tf, terraform.tf
etc.) are gitignored, if deployments haven't been ran locally before committing terraform file changes, the pre-commit terraform checks might fail and give output like this:We ideally need to be able to tell the pre-commit hooks to run a terragrunt init before the terraform checks. We do this currently in the pr checks workflow but that only prevents this in GH, not locally.