-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Description
Terraform Version
Was able to reproduce it on a variety of versions starting from 0.13.5 and up to the latest.
Terraform Configuration Files
# main.tf
resource "null_resource" "cluster" {}
resource "random_string" "random" {
length = 5
}Expected Behavior
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Actual Behavior
Error: Failed to install provider from shared cache
Error while importing hashicorp/null v3.1.0 from the shared cache directory:
after linking registry.terraform.io/hashicorp/null from provider cache at
/Users/kryvenkd/repos/tmp/tf-plugin-cache it is still not detected in the
target directory; this is a bug in Terraform.
Steps to Reproduce
export TF_PLUGIN_CACHE_DIR=~/repos/tmp/tf-plugin-cachetf initrm -rf ${TF_PLUGIN_CACHE_DIR}/registry.terraform.io/hashicorp/randomtf init
This is tricky one to reproduce - there must be at least two providers at play, and also deleting null provider doesn't reproduce this - but other providers does.
Additional Context
The goal here is basically to do as explained here https://learn.hashicorp.com/tutorials/terraform/automate-terraform#plan-and-apply-on-different-machines.
In my CI I archive everything from the workspace during the plan and then restore for apply. The trick is TF_PLUGIN_CACHE_DIR volume might be different than have used during the plan, and it might not have providers that were previously installed during the plan. That resulting in .terraform/providers having broken symlinks. I think TF should not freak out if the symlink leads to nowhere but simply fallback to re-downloading the provider.