terraform
terraform copied to clipboard
Clarifiy plugin_cache_dir behavior
Terraform Version
terraform -version
Terraform v1.8.5
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v5.54.1
Affected Pages
https://developer.hashicorp.com/terraform/cli/config/config-file#provider-plugin-cache
What is the docs issue?
The docs state under section "Provider Plugin Cache":
Given that provider plugins can be quite large (on the order of hundreds of megabytes), this default behavior can be inconvenient for those with slow or metered Internet connections. Therefore Terraform optionally allows the use of a local directory as a shared plugin cache, which then allows each distinct plugin binary to be downloaded only once.
This is wrong, it is not downloaded once, it is only stored once. Everytime terraform init is executed in a different working directory, it will download the plugin again, even if it exisits in the plugin_cache_dir already.
TF_PLUGIN_CACHE_DIR="$HOME/.terraform.d/plugin-cache" terraform init
Initializing provider plugins...
- Finding hashicorp/aws versions matching "~> 5.0"...
- Installing hashicorp/aws v5.54.1...
- Installed hashicorp/aws v5.54.1 (signed by HashiCorp)
On a side note: Only using TF_PLUGIN_CACHE_MAY_BREAK_DEPENDENCY_LOCK_FILE=1 will lead to Using hashicorp/aws v5.54.1 from the shared cache directory
but of course will lead to a warning:
│ Warning: Incomplete lock file information for providers
│
│ Due to your customized provider installation methods, Terraform was forced to calculate lock file checksums locally for the following providers:
│ - hashicorp/aws
Proposal
No response
References
No response