Error configuring Terraform Community Providers

Hi, folks.

I’m trying to create a Redshift datashare, receiving a readonly cluster as a datashare.
However, since the AWS provider is missing, I’m trying to set up a community provider, but I’m getting the following error. I’m not sure where or how to fix it. Any help would be appreciated!

  • Original Terraform configuration:
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 3.72"
    }
...
    kubectl = {
      source  = "gavinbunney/kubectl"
      version = ">= 1.14.0"
    }
    redshift = {
      source  = "techindicium/redshift"
      version = "0.5.1"
    }
  }
}
  • Provider block in my Terraform configuration:
provider "redshift" {
  host = data.aws_redshift_cluster.this.endpoint
  username = data.aws_redshift_cluster_master.this.name
  password = data.aws_secretsmanager_secret.this.arn
}
  • Error message:
│ Error: Failed to query available provider packages
│ 
│ Could not retrieve the list of available versions for provider hashicorp/redshift: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/redshift
│ 
│ Did you intend to use techindicium/redshift? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on hashicorp/redshift, run the following command:
│     terraform providers
Error: Failed to query available provider packages

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

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

The error message is indicating that Terraform couldn’t find the hashicorp/redshift provider. Instead, it suggests using the techindicium/redshift provider and advises updating the source address in each module requiring that provider.

Hi @zitrocy,

The error is typically caused by a module not declaring the proper required_providers, so Terraform is assuming that the missing provider must be in the hashicorp/ namespace. Did you run the terraform providers command suggested in the error message? That should show where the implied hashicorp/redshift provider is being found.

1 Like

Thanks for the reply, jbardin!

This is what I got running terraform providers.

├── module.center_redshift_readonly
│   ├── provider[registry.terraform.io/hashicorp/aws]
│   └── provider[registry.terraform.io/hashicorp/redshift]

still having a problem here.

I’ve set provider file as below :

provider "redshift" {
  alias    = "techindicium"
  host     = data.aws_redshift_cluster.this.endpoint
  username = data.aws_redshift_cluster_master.this.name
  password = data.aws_secretsmanager_secret.this.arn
}

version file as below :

    redshift = {
      version = "0.5.1"
    }

and it still not working… :frowning:

Hi @zitrocy,

I can’t tell exactly what you need without a complete example, but to start I think you need to add the redshift provider to the required_providers in the center_redshift_readonly module configuration so that Terraform knows what specific providers it requires.

The actual provider configuration block should be in the root module, and passed into the child modules with the providers argument.

See the documentation here for more details: Providers Within Modules - Configuration Language | Terraform | HashiCorp Developer

1 Like

Thanks, @jbardin for the note!
In the version file, redshift is set to required_providers,
And in the root module, I’ve passed into the child modules with the providers argument

  providers = {
    redshift = redshift.redshift_cluster
  }

Here’s my code.
What I want to do is to create a cluster that receives a data share.

module "redshift_cluster” {
  source                 = "../../modules/aws_redshift"
  cluster_type           = "single-node"
  …
  name                   = “name-of-the-cluster”
  node_type              = "dc2.large"
  short_env              = local.short_env
  number_of_nodes        = 1
  subnet_ids             = local.private_subnets
  …
  encrypted              = true
  datashare_name = “datashare_name”
  providers = {
    redshift = redshift.redshift_cluster
  }
}

and this is for the response for the terraform plan.

│ The local name “redshift.redshift_cluster” in the root module represents provider “techindicium/redshift”, but “redshift” in module.redshift_cluster represents “hashicorp/redshift”.

│ Each provider has its own distinct configuration schema and provider types, so this module’s “redshift” can be assigned only a configuration for hashicorp/redshift, which is not required by module. redshift_cluster

Hi @zitrocy ,

It seems that your child module doesn’t declare that it uses this provider, and so Terraform’s backward compatibility rule is activated too assume you meant an official provider.

The error message suggests that you already have a suitable required_providers block in your root module. You should include a similar block in each of your modules that uses this provider, so Terraform can know which provider each of the modules is depending on.

1 Like