-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
website: "terraform init" documentation could link to the relevant CLI config settings #26693
Comments
Hi @joe-a-t! Thanks for sharing this use-case. What you've described does seem valid and interesting, though I was a little confused at first due to some differences in terminology in your write-up compared to what we typically use in our documentation. Just so we can be sure we're all talking about the same thing, I want to define some terms:
With those terms defined, I think you are describing the main use-case for the opt-in provider cache, but you've been trying to meet that use-case using a filesystem mirror directory and thus finding it doesn't quite meet your needs. I'd be interested to hear if you've tried (or would be willing to try) the provider cache feature as I linked above, and whether that better meets the use-cases you've described here. If it doesn't, we may prefer to meet the use-cases you've described by adjusting the provider cache behaviors rather than by adding a new operating mode entirely, because that feature is already designed to maintain a read-through cache and so I expect it would be a smaller change compared to the current behavior. Another related enhancement we could consider based on this feedback is to optimize |
Hey @apparentlymart, thanks a lot for the response. Yes, I tried it out and it looks like the provider cache you linked to works for most of my use case. I hadn't come across that since I don't see it mentioned on https://www.terraform.io/docs/commands/init.html, https://learn.hashicorp.com/tutorials/terraform/automate-terraform, or https://www.terraform.io/docs/extend/how-terraform-works.html#discovery. Could we update those docs to include mention of the As far as improvements to the It would also be a huge help if this sort of caching was extended to include modules, I know #16268 has been hanging around for quite a while but it would provide immense performance improvements for my use case if something similar could be implemented for module caching. |
Hi again @joe-a-t! Thanks for following up with that additional information. I'm glad to hear that the cache directory was a better fit for your use-case. I think there's maybe three enhancement requests in your comment here:
With all of that said, I'm going to relabel this issue to represent the documentation addition you mentioned because I agree that it's weird not to have a connection from the command that does the installation to the settings that command respects. I don't expect we'll add a cache-related command line option to Thanks again for raising this! |
As part of revising the The new version of the documentation will be published to the website as part of the v0.14.0 final release, which we're planning to make in a few weeks as long as there's no blocking feedback from the current v0.14.0-rc1 prerelease. |
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. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Current Terraform Version
Use-cases
Any terraform usage (but most commonly by automation) that iterates through multiple terraform directories that have the same provider(s) but does not desire strict provider versioning and would like the process to be faster and more efficient.
Attempted Solutions
Thanks to the great improvements in https://www.terraform.io/upgrade-guides/0-13.html#new-filesystem-layout-for-local-copies-of-providers with
terraform providers mirror
, caching providers is now much easier to implement. However, theterraform providers mirror
command downloads all providers in the current directory, even if they already exist in the cache. This prevents runningterraform providers mirror
in every terraform directory since that would invalidate the entire point of using a cache. As a result, we have to manually compile a list of providers to put in the cache and populate it in advance.Additionally, if
terraform init
tries to get a specific version of a provider where the provider exists in the cache but not at that specific version, it is a hard fail instead of reaching out to the remote source to download the provider as it would if no versions of the provider existed in the cache.Proposal
I would like to propose adding a
-populate-cache
flag toterraform init
. The behavior of this flag would be to:-upgrade
, checks the remote to see what the latest allowed version is, then continue to next steps a with request for the latest allowed version number.~/.terraform.d
for the provider and latest allowed version.This would lead to significant performance improvements since any providers are only getting downloaded from their remote sources once, regardless of how many terraform directories use them. This would also avoid the need to pre-provision the cache and the management overhead it entails.
Ideally, this could also be extended to include modules per #16268.
To boost the urgency of the issue, I want to point out that it should lower Hashicorp's cloud costs since they receive fewer requests to download assets they host and as a result need fewer servers and pay for less network bandwidth. This may one day be worth changing the default behavior of
terraform init
to automatically store all downloaded providers/modules in~/.terraform.d
but I think the safest route is to make it available behind a flag and change the default behavior later if people like the change and start using it everywhere.References
#16268
The text was updated successfully, but these errors were encountered: