minamijoyo / tfupdate

Update version constraints in your Terraform configurations
MIT License
539 stars 23 forks source link

Support .terraform.lock.hcl files when upgrading providers #68

Closed jrobison-sb closed 1 year ago

jrobison-sb commented 2 years ago

Terraform 0.14 and higher uses .terraform.lock.hcl files with a hash of each provider/platform to be used. It would be nice if tfupdate was able to auto-update these lock files when upgrading providers. For example:

tfupdate --version 1.2.3 --recursive --platform darwin_amd64 --platform linux_amd64 aws ./

And this would do what tfupdate already does, and it would also do the equivalent of terraform providers lock -platform=darwin_amd64 -platform=linux_amd64 and recursively update all the lockfiles.

minamijoyo commented 2 years ago

Hi @jrobison-sb, Thank you for your proposal.

Yes, the lock file management is very annoying due to the current technical limitation of the Terraform core and registry.

The current workaround is https://github.com/minamijoyo/tfupdate/issues/32 The root cause of this problem is described in the upstream issue https://github.com/hashicorp/terraform/issues/27264

In short, without support for providing h1 hashes in the Terraform registry, we need to reimplement a lot of terraform internals and it would be hard to support multiple terraform versions in a stable way.

Having that said, I agree with that it would be great if the tfupdate updates not only version constraints, but also lock files, so I keep this issue open as a feature request.

Thanks!

minamijoyo commented 1 year ago

The tfupdate v0.7.0 introduced a new tfupdate lock command. For details, see https://github.com/minamijoyo/tfupdate/pull/90