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.31k stars 9.49k forks source link

Feature request: Caching the providers locally in user home folder #30106

Closed samuraifox1 closed 2 years ago

samuraifox1 commented 2 years ago

Hello there, Having a caching mechanism similar to docker (image layers) for the terraform provider plugins would be great for local development. The command terraform init fetches the providers first time. But this becomes cumbersome when I have to work multiple times per day across multiple projects. e.g. for azurerm (latest) the file size (.terraform\providers\registry.terraform.io\hashicorp\azurerm\2.88.1\linux_amd64\terraform-provider-azurerm_v2.88.1_x5) is about 176 MB. It would be great to locally cache the this in user home folder and let the terraform copy it in working folder.

(Please close this if there is way to control such behaviour). Best regards

samuraifox1 commented 2 years ago

Or progress bar please ? image

KylePeterDavies commented 2 years ago

Hey @samuraifox1

Have you looked at the .terrafomrc? You can cache providers with this.

plugin_cache_dir   = "$HOME/.terraform.d/plugin-cache"

CLI Configuration

samuraifox1 commented 2 years ago

Ok, I will check. Kindly close this. Thanks a lot!

nl-brett-stime commented 2 years ago

Kindly close this.

I think this would still be useful. We have tens of Terraform projects, a handful of root modules for each project to initialize backends in different account/environments and different versions of TF templates available from our CI/CD artifact repos. This leads to initializing a lot of different root directories and the hashicorp/aws provider isn't getting any lighter weight.

It'd be great if Terraform were to cache modules and providers centrally for re-use between different projects/roots on the same machine.

nl-brett-stime commented 2 years ago

Sorry I missed the note about .terraformrc. I thought this was saying that TF already caches in the working root directory which is good--but if .terraformrc also caches between working root directories, that's even better..

crw commented 2 years ago

I believe this issue is resolved, and I failed to kindly close it last time. I'm going to do so now, please let me know if I am missing something (although it may be better to open a new issue using the official template if there is still an unanswered request in this thread).

github-actions[bot] commented 2 years ago

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.