Skip to content

Provider Cache Server clarification (and possible bug) #5061

Description

@dave-v

The Provider Cache Server feature ensures that each provider is only ever downloaded and stored on disk exactly once1

I work on a large Terragrunt/Terraform project with hundreds of terragrunt.hcl files, and no matter how much I fiddle with the provider cache server feature, providers are being duplicated on disk. This means I often end up with ~200GB of providers in my cache directory. I've read through all the pre-existing issues on the subject I could find, but that has not yielded any success.

I am running commands such terragrunt run --all apply from various subdirectories with the following environment variables:

TF_PLUGIN_CACHE_DIR=C:\.terraform-cache
TG_DOWNLOAD_DIR=C:\.terragrunt-cache
TG_PROVIDER_CACHE=1
TG_PROVIDER_CACHE_DIR=C:\.terragrunt-cache\providers

When I start up, log messages indicate the provider cache server is running successfully.

Every unit in the run has log messages such as:

[s3] Downloading Terraform configurations from {repo-directory} into C:/.terragrunt-cache/IaOznkz2RQHNlRPWSzBWj26t9gc/u_SjJeLIAzG6p_jjY4-Rcxi8KCo
[s3] Caching terraform providers for C:/.terragrunt-cache/IaOznkz2RQHNlRPWSzBWj26t9gc/u_SjJeLIAzG6p_jjY4-Rcxi8KCo/modules/s3

The second message only appears if the cache directory didn't already exist.

And C:/.terragrunt-cache/IaOznkz2RQHNlRPWSzBWj26t9gc/u_SjJeLIAzG6p_jjY4-Rcxi8KCo contains a copy of my entire directory structure for the project with the provider binary for the unit in question copied into the relevant module's subtree.

The entire directory tree being duplicated for every unit seems excessive already, but that's not such an issue on its own compared to the large provider binaries being duplicated everywhere too. My understanding of the provider cache server mechanism is that this should not happen, but I'm not entirely convinced I understand how it is supposed to behave, therefore I didn't open this as a bug.

I do have a single copy of all the providers located in my TG_PROVIDER_CACHE_DIR directory, and I would have expected these to be used rather than being copied each time.

Since I'm on Windows, I'm wondering if it might be an issue with symbolic links?

I am running on:
Windows 10
Terragrunt v0.93.0 (I was also seeing the same behaviour on v0.57.9)
Terraform 1.13.4

TL;DR: Despite using the provider cache server, provider binaries are being duplicated once per terragrunt.hcl file that gets initialised. Have I misunderstood the provider cache server feature or does it look like a probable bug?

Many thanks for any help!

Footnotes

  1. https://terragrunt.gruntwork.io/docs/features/provider-cache-server/

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpreservedPreserved issues never go stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions