Open a18-kaushik opened 1 year ago
Hi @a18-kaushik,
Can you please verify that the behavior is the same on a current release of Terraform? Some behaviors have changed and bugs have been fixed since the v1.0 releases.
Thanks!
Hi @jbardin i tried with version 1.4.2 but the problem persists
debug logs:
Initializing provider plugins...
@jbardin did you get a chance to look into this? thanks
I upgraded from v1.3.x to v1.4.x, looks like install from caching
no longer works, or at least no longer works as expected.
I have multiple stack folders using the same providers, terraform init
installs all of the providers in the first stack folder, but it still downloads the same in the following folders not from cache.
@a18-kaushik, The error is a Windows error from linking the provider files. It will take some time to reproduce and investigate what exactly is failing on that platform.
@jbardin okay noted!
I believe I have this issue on Linux (amd64) too with Terraform 1.4.6. Terraform will scan my plugin-cache, find appropriate versions of the (in this case) AWS provider, and proceed to re-download it anyway. There seem to be no logs in the TF_LOG=TRACE
that say why it decided to redownload the provider.
It may also be re-downloading other providers constantly too, but since they're much smaller it's harder to notice.
The plugin cache used to work correctly, I'm unsure when it broke, but it's definitely been months for me at this point.
version 1.5.2 on Mac(amd64) is same behavior `Initializing provider plugins...
I believe that if the .terraform.lock.hcl file is absent, local caching will not be utilized.
https://github.com/hashicorp/terraform/blob/v1.4.6/internal/providercache/installer.go#L387-L398
Same thing happens to me (on Linux), where I have to use plugin_cache_may_break_dependency_lock_file = true
to make the cache to work. This isn't an issue back in the v1.3.x.
Same. Essentially if the there is no lock file it will always download from upstream and not respect the plugin_cache. For me setting plugin_cache_may_break_dependency_lock_file does not help and it still redownloads it.
My unfortunate work around is to pin the aws provider version and copy in a .terraform.lock.hcl file with the hashes. Whicht seems like this is expected behavior but I don't understand the reasoning behind this decision.
// An existing cache entry is only an acceptable choice
// if there is already a lock file entry for this provider
// and the cache entry matches its checksums.
//
// If there was no lock file entry at all then we need to
// install the package for real so that we can lock as complete
// as possible a set of checksums for all of this provider's
// packages.
Same problem here with MacOS ARM64 and TF 1.5.7. Rolled back to using TF 1.3.10.
Same thing happens to me (on Linux), where I have to use
plugin_cache_may_break_dependency_lock_file = true
to make the cache to work. This isn't an issue back in the v1.3.x.
can confirm. Only accesses the local plugin cache if I set the environment variable.
Terraform v1.7.3
on linux_amd64
but: this may be okay if I understood the docs correctly.
By default Terraform will use packages from the global cache directory only if they match at least one of the checksums recorded in the dependency lock file for that provider.
in my case, I regenerate the dependency lock file each time. (as the terraform code gets generated by some other tooling) This is why I have to set that flag to make things work.
Terraform Version
Terraform Configuration Files
Debug Output
Initializing provider plugins...
Expected Behavior
terraform init execute successfully with cache provider
Actual Behavior
Error: Failed to install provider │ │ Error while installing hashicorp/aws v4.60.0: failed to create directory │ C:\Users\a18.kaushik\Desktop.terraform\providers\registry.terraform.io\hashicorp\aws\4.60.0\windows_amd64: │ mkdir │ C:\Users\a18.kaushik\Desktop.terraform\providers\registry.terraform.io\hashicorp\aws\4.60.0\windows_amd64: │ Cannot create a file when that file already exists.
Steps to Reproduce
Additional Context
followed documentation for provider plugin cache : https://developer.hashicorp.com/terraform/cli/config/config-file#provider-installation
References
No response