Skip to main content
Knowledge Base

Shared "Cache" of Terraform Providers

Answer

Greetings! I am trying to accomplish something, that I know must be possible and I am just missing it in the documentation. I am trying to make it so that I can have a shared cache of Terraform Providers that is used by ALL modules within my Terragrunt Project. I have over 475 modules (all AWS based), and it doesn't seem sane to me that I would need to download the AWS provider 475 times, when once should be all that is required. I have tried using the terragrunt-cache mechanism, but as noted I then have to limit parrallelism to 1. Is there a better way? --- <ins datetime="2024-03-25T14:46:44Z"> <p><a href="https://support.gruntwork.io/hc/requests/110845">Tracked in ticket #110845</a></p> </ins>

Hey @dhoffman-vertex ! There is a long, in-depth discussion about this topic [here](https://github.com/gruntwork-io/terragrunt/issues/2920). The TLDR is that you can use [standard provider plugin caching](https://developer.hashicorp.com/terraform/cli/config/config-file#provider-plugin-cache), but you can experience errors when running multiple Terragrunt operations concurrently while using it, as Terraform has no locking mechanism that makes it safe to access from multiple concurrent sources. The simplest way to mitigate that drawback is to init with a parallelism of 1, then run the operation you want without limiting parallelism. That will populate the shared provider cache in a sequential fashion, then the plan, apply, etc can be run in parallel.