Skip to content

Commit 02c1935

Browse files
fix(terraform_providers_lock): Require terraform init (and terraform_validate hook) run when only lockfile changed (#649)
### Description of your changes ![image](https://github.com/antonbabenko/pre-commit-terraform/assets/11096782/50022937-7360-4c3b-8919-a488730c493a) When the terraform root module contains any child module it requires `terraform init` to run to be able to successfully run the provider lock operation. Previously, `terraform init` was in `terraform_providers_lock` hook too, but moved out to be only in `terraform_validate`, because there was little sense in trying to lock anything that was code invalid. If we return `terraform init` back to `terraform_providers_lock` - major changes in providers that remove resources etc. can be successfully written to lockfile without any checks, as such checks done in `terraform_validate` ## Workaround till the release of that stuff Add `files: (\.tf|\.tfvars|\.terraform\.lock\.hcl)$` to `terraform_validate` hook call --- Co-authored-by: George L. Yermulnik <[email protected]>
1 parent 495357e commit 02c1935

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

.pre-commit-hooks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
require_serial: true
4949
entry: hooks/terraform_validate.sh
5050
language: script
51-
files: (\.tf|\.tfvars)$
51+
files: \.(tf(vars)?|terraform\.lock\.hcl)$
5252
exclude: \.terraform/.*$
5353

5454
- id: terraform_providers_lock

0 commit comments

Comments
 (0)