Help with terraform local registry and init issues

Hi folks,

Building a docker image with terraform in it to perform some tf upgrades. The issue I am having is I have configured my .terraformrc file with a filesystem_mirror pointing to a local directory on the image that has a registry.terraform.io folder structure.

provider_installation {
  filesystem_mirror {
    path = "/root/.tfproviders"
    include = ["registry.terraform.io/*/*"]
    }
}

However during terraform init, I am not specifying a plugin cache directory and the init fails with “Failed to validate installed provider. Validating provider hashicorp/tls v4.0.6 failed: lstat rootfs: so such file or directory”

Should I have to specify a plugin cache during my tf init run? The only docs for that say to use a folder like $HOME/.terraform.d/plugin_cache/linux_amd64 and put all the providers in the root of that folder. I don’t think I should need two locations for these providers.

Overall I’m not sure what I’m doing wrong here. The docs seem conflicting on how to properly use a local registry, but it works on my RHEL box. Any advice? TYIA

CB

Hi @cwb124,

I’m not sure what could be going on here, it would help to have a more complete example of the failure.

Which layout are you using for the filesystem_mirror?

The cache isn’t directly related to the mirror, but if the mirror is contained within the docker image then I don’t think you would need the cache too. Terraform is going to try and symlink the local directories when possible, so make sure things are laid out the same in each layer of your docker files.

Thanks for the response. To answer your question, here is a sample folder structure for a module:
/root/.tfproviders/registry.terraform.io/hashicorp/tls/4.0.6/linux_amd64

I enabled trace logging and it’s frustrating because the logs show that it’s finding the modules in those folders. It’s even copying the modules properly into the .terraform folder it creates when it runs terraform init. It’s just “failed to validate installed provider” for all of the 4 modules I am trying to use. Just at the end of my rope here with this.