-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Lock file generation is inconsistant #31194
Comments
Hi @tmccombs! Thanks for reporting this. This is indeed essentially a restatement of the other issue you liked to, #27811. The crux of the problem is that if you customise Terraform's provider installation settings in a way that prevents it from talking to the provider's origin registry then Terraform can't get the signed set of checksums created by the provider author and so it must fall back on the less thorough behavior of calculating a checksum locally from whatever single package it does have access to. The main way to avoid this is to use the default provider installation strategy (no mirrors or caching at all) during development, and reserve the special settings only for situations such as running Terraform in an automated pipeline, where the configuration is treated as read-only and so there should be no changes to the lock file. You can reinforce the latter by having the automation run As this situation is already represented in a number of issues, I don't think this new one will cause any different outcome than the others would: there is still the threat modelling question to be answered about whether trusting a mirror or cache as a source for the official checksums of a provider is valid or if it undermines the checksum scheme by allowing a hypothetical attacker to inject rogue checksums into the system that would then be trusted by downstream users of the lock file, and #27811 is already asking that question so I think we can consider this one to be a duplicate of that one, and thus I'm going to close this. Thanks again! |
That isn't a great option. In development I have a large number of projects that use the same providers. And using it without a cache results in making init substantially slower (at least on the first run), and significantly higher disk usage. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Terraform Version
Terraform Configuration Files
Expected Behavior
terraform init
, orterraform init -upgrade
should generate all necessary hashes, and runningterraform init
even on another host shouldn't change the .terraform.lock.hcl file.Actual Behavior
Sometimes when I run
terraform init
orterraform init -upgrade
it will populate hte .terraform.lock.hcl file, but the only hash in the hashes array will be theh1
hash. Then later, someone else will run aterraform init
, and it will add a bunch ofzh
hashes to the lockfile. I'm not entirely sure what the situation is that leads to this. Maybe something to do with the provider already being cached?Since we check the .terraform.lock.hcl files into our git repo, this can be pretty annoying since someone will make an unrelated change (to say updating a provider), but it will update the lock file.
Running
terraform providers lock
will also add thezh
hashes.Steps to Reproduce
terraform init
orterraform init -upgrade
on one machineterraform init
on a separate host. sometimes, I don't know exactly what conditions trigger it.terraform providers lock
it will also add a bunch ofReferences
Probably related to #27811
The text was updated successfully, but these errors were encountered: