Add an example for updating .terraform.lock.hcl#113
Merged
minamijoyo merged 7 commits intomasterfrom Dec 4, 2020
Merged
Conversation
Terraform v0.14 will introduce a dependency lock file named `.terraform.lock.hcl`. https://discuss.hashicorp.com/t/terraform-0-14-the-dependency-lock-file/15696 The lock file is an implementation detail and it's hard to update it with the tfupdate command. Because the hash value format seems to allow future terraform versions to change the hash algorithm gradually. If tfupdate updates the lock file, it will be difficult to support multiple terraform versions without an unexpected the lock file drift. Perhaps a recommended way is to use the terraform command to update the lock file. However most CIs use linux and laptops may be mac or windows and if you run terraform on multiple platforms, it requires to generate hashed for all platforms to avoid a lock file drift. So I added an example for it, but I found it's inefficient because it requires duplicate downloads for providers on init. I tried to use a plugin cache dir or a local filesystem mirror, but I couldn't figure out a way to avoid duplicate downloads on init. If I use cache or mirror, it doesn't record zip hashes, and it records them only when download providers from origin. I think the easiest way to use Terraform v0.14 with tfupdate is adding .terraform.lock.hcl to .gitignore.
5be57b9 to
fe7b127
Compare
I found the terraform providers lock command doesn't require init.
fe7b127 to
5d51d2c
Compare
This reverts commit 5d51d2c. I found using only h1 hases would avoid duplicate downloads
It works fine as long as the .terraform.lock.hcl is generated on CI. Note that if you run terraform init -upgrade manually, it will add zh hases, so you should not do.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I added an example for updating
.terraform.lock.hcl.For details, see: minamijoyo/tfupdate#32
An example for Pull Request generated by this branch can be found in #124