0
votes

hello I use the version v13 of terraform since the release of this version we are forced to go through the version.tf system with the required_providers block. CF https://www.terraform.io/docs/configuration/provider-requirements.html .

I have a main.tf script that call sub module terraform. like below

module "wab_device" {
  
  source        = "./wab-device"
  domain        = "aws.eu-west-1.example.com"
  os            = "Linux"
  hostnames     = { "JTUFFZ06TEST" : { "vm_name" : "JTUFFZ06TEST" } }
  description   = "Test description use module wab tfv13"
  support_group = "Support group"
}

and i have my version.tf like below

terraform {
  required_providers {
    wab = {
      source  = "private-registry.example.com/org/wab"
      version = "1.3.2"
    }
    vault = {
      source = "hashicorp/vault"
    }
  }
  required_version = ">= 0.13"
}

so far, so good

i launch my terraform13 init i faced the issue below

Error: Failed to install provider

Error while installing hashicorp/wab: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/wab

terraform doesn't find the providers on my private registry inside my module . i try to download from internet so i copy paste the version.tf in the directory ./wab-device

And it's work like a charm.

But in theory is ok . in pratice i can't modified my module wab-device beacause it's a git repo and i'm not owner and i have to do the same thing with 5 other repos...

How can we use the module without specify the version.tf inside the submodule . Can i use Alias instead ?? or .terraformrc

Thanks for your advices i would help me

regards

1
You would need to modify this in the wab-device module config. If you are not an owner, you can still PR the change.Matt Schuchard

1 Answers

0
votes

In Terraform, each module is responsible for declaring its own dependencies. This is similar to how in most other programming language ecosystems a library will declare which other libraries it depends on.

For that reason, it isn't possible to force a module to depend on a new provider it doesn't already depend on. You'd need to either ask the maintainer of that module to add the necessary dependency declaration, or fork the module and add the declaration to your copy.

Since this "wab" module isn't one of the providers that HashiCorp itself was distributing prior to Terraform v0.13, it's likely that the modules you are trying to use are designed for Terraform v0.12 rather than Terraform v0.13. In that case, an alternative approach would be to use Terraform v0.12 for your configuration too, and remain on that version until all of the modules you depend on are updated to be compatible with Terraform v0.13.