Mongey/terraform-provider-kafka

Defining the provider in a module outside the root module Error: Failed to query available provider packages

mdkouki opened this issue · 1 comments

Hello, let me first thank you for the big effort afforded in this project,

We are trying to use module to define the provider to be reused for topics creation for each project seprately like this :

modules/providers.tf
project1/topics1.tf
project2/topics2.tf

with topic1.tf and topic2.tf start by:

module "common" {
source = "../modules"
}

a terraform init inside project1 directory gives
│ Error: Failed to query available provider packages

│ Could not retrieve the list of available versions for provider hashicorp/kafka: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/kafka

│ Did you intend to use mongey/kafka? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on hashicorp/kafka, run the following command:
│ terraform providers

the terraform providers gives

Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/kafka]
└── module.common
└── provider[registry.terraform.io/mongey/kafka] 0.3.3

Any solution to resolve this issue ?
Thanks in advance

You need to define required_providers at the root level.

terraform {
  required_providers {
    kafka = {
      source = "Mongey/kafka"
    }
  }
}