hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io
Other
42.83k stars 9.57k forks source link

Provide an automated way of using a default list of provider platforms when lock files get created/updated #33972

Open snuggie12 opened 1 year ago

snuggie12 commented 1 year ago

Terraform Version

Terraform v1.3.8
on darwin_amd64

Use Cases

When you have multiple platforms which are not your own in a shared environment it is quite annoying to constantly remember after doing work that your provider lock file has been altered and you need to also remember the correct incantation to add other processors and other OS's back to your lock file.

Attempted Solutions

There are lots of work arounds like making your own pre-commit hook, making a meanly named shell alias, a CI based solution, etc. However, rather than a bunch of people re-inventing the wheel something like a config/preferences file in your home directory or something similar seems a lot easier.

Proposal

As mentioned above, my initial idea would probably a file in your home dir, but anything similar where you set it once and forget about it would be just fine.

References

I couldn't find any, though lots of people mention a plugins directory. I don't think that's related, but I don't know how the provider lock system works.

crw commented 1 year ago

Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!

caius commented 12 months ago

Had a similar thought occur to me after searching my shell history for the correct terraform providers lock incantation I used last time I added a provider to the current terraform repo I'm working in.

my initial idea would probably a file in your home dir

I think a per-workspace setting would be more appropriate, I might have to collaborate on different repos which run on different architectures/OS's separately and would need different lockfiles generating.

I wonder if this could be added to the terraform {} configuration block like we have required_version for terraform. Would keep it scoped to the workspace, and keeps it in source control too.

Possibly allowing for falling back to TERRAFORM_PROVIDER_LOCK_PLATFORMS for the generic "configure my machine for all repos" use case?

terraform {
  provider_lock_platforms = [
    "darwin_arm64",
    "linux_amd64",
  ]
}