-
-
Notifications
You must be signed in to change notification settings - Fork 546
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
Reinitialize if module version requirement changed #299
Comments
Hi Johannes, Terraform does not give us a way to know what exactly is wrong: Provider or module version changed? Not initialized modules? The wrong version of Terraform? Or something else? The easiest way for users right now is to remove In the long run, we may implement force-init, as described here - #224 Closing for now. |
https://github.com/antonbabenko/pre-commit-terraform#terraform_validate - there is a function to remove |
Hi Anton, Thanks for the quick feedback and the link (I saw this one). I agree that Terraform gives you no hint currently. |
As a user, I agree. But as a developer, it is still tricky to try to guess if the error is retriable or a hard failure. Doing regexp matches on error messages to decide if it should retry can be rather error-prone (Terraform can change error messages any time). |
Yes, you're totally right that regexp matches on error messages aren't a good idea. |
pre-commit does not know what is "git changes". It is often executed without relation to history, not right before doing a commit (despite the name - |
Ok, didn't knew that, I was thinking of running Last one (and then I'm really quiet, I promise 🤞 ): So, line 93 of
and would always trigger a |
Thanks for the suggestion! If I have just updated #224 issue. I am not sure when or who will be able to work on it. Feel free to contribute if you have time. |
What problem are you facing?
I wanted to switch from gruntwork/terraform-validate pre-commit hook to pre-commit-terraform/terraform_validate. So far so good, but when I changed a module version in my code I got the following error:
I never got such an error with the gruntwork hook and I figured out that the gruntwork hook just always run
terraform init -backend=false
.The terraform_validate hook only runs
terraform init
if there's no.terraform
directory --> https://github.com/antonbabenko/pre-commit-terraform/blob/master/terraform_validate.sh#L93How could pre-commit-terraform help solve your problem?
Honestly, I'm a fan of not running
terraform init
all the time, as it makes pre-commit checks faster overall.On the other side I don't like to think about manually deleting
.terraform
andterraform.lock.hcl
whenever I want to change to a different module version.It would be great of terraform_validate would be aware of module version changes and rerun
terraform init
if needed.The text was updated successfully, but these errors were encountered: