Skip to content
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

Add an example for updating .terraform.lock.hcl #113

Merged
merged 7 commits into from
Dec 4, 2020

Conversation

minamijoyo
Copy link
Owner

@minamijoyo minamijoyo commented Nov 22, 2020

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

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.
@minamijoyo minamijoyo force-pushed the tfupdate-test-for-v0.14 branch 2 times, most recently from 5be57b9 to fe7b127 Compare November 22, 2020 15:47
I found the terraform providers lock command doesn't require init.
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.
@minamijoyo minamijoyo merged commit 610ef07 into master Dec 4, 2020
@minamijoyo minamijoyo deleted the tfupdate-test-for-v0.14 branch December 4, 2020 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant