mongodb / terraform-provider-mongodbatlas

Terraform MongoDB Atlas Provider: Deploy, update, and manage MongoDB Atlas infrastructure as code through HashiCorp Terraform
https://registry.terraform.io/providers/mongodb/mongodbatlas
Mozilla Public License 2.0
241 stars 167 forks source link

provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/mongodbatlas #1389

Closed omerls-pw closed 1 year ago

omerls-pw commented 1 year ago
Terraform v1.5.4
on darwin_arm64
+ provider registry.terraform.io/gavinbunney/kubectl v1.14.0
+ provider registry.terraform.io/hashicorp/aws v5.6.2
+ provider registry.terraform.io/hashicorp/helm v2.10.1
+ provider registry.terraform.io/hashicorp/kubernetes v2.21.1
+ provider registry.terraform.io/hashicorp/null v3.2.1
+ provider registry.terraform.io/hashicorp/random v3.5.1
+ provider registry.terraform.io/hashicorp/time v0.9.1
+ provider registry.terraform.io/mongodb/mongodbatlas v1.11.0

Terraform Configuration File

provider "mongodbatlas" {
  private_key = local.mongodb_apikey.privateKey
  public_key  = local.mongodb_apikey.publicKey
}

Steps to Reproduce

1. `terraform init`

raising an error:

│ Error: Failed to query available provider packages
│ 
│ Could not retrieve the list of available versions for provider hashicorp/mongodbatlas: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/mongodbatlas
│ 
│ Did you intend to use mongodb/mongodbatlas? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on hashicorp/mongodbatlas, run the
│ following command:
│     terraform providers

Expected Behavior

Download the provider code

Actual Behavior

│ Error: Failed to query available provider packages
│ 
│ Could not retrieve the list of available versions for provider hashicorp/mongodbatlas: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/mongodbatlas
│ 
│ Did you intend to use mongodb/mongodbatlas? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on hashicorp/mongodbatlas, run the
│ following command:
│     terraform providers

Debug Output

Crash Output

│ Error: Failed to query available provider packages
│ 
│ Could not retrieve the list of available versions for provider hashicorp/mongodbatlas: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/mongodbatlas
│ 
│ Did you intend to use mongodb/mongodbatlas? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on hashicorp/mongodbatlas, run the
│ following command:
│     terraform providers

Additional Context

References

github-actions[bot] commented 1 year ago

Thanks for opening this issue. The ticket INTMDB-1012 was created for internal tracking.

andreaangiolillo commented 1 year ago

Hello @omerls-pw Could you share the required_providers block used in your configuration?

This is an example of the required_providers block to use our provider:

terraform {
  required_providers {
    mongodbatlas = {
      source  = "mongodb/mongodbatlas"
      version = "1.11.0"
    }
  }
  required_version = ">= 1.0"
}

Thanks

omerls-pw commented 1 year ago

I didn't have any. I added it to the code. It looks like this now:

terraform {
  required_providers {
    mongodbatlas = {
      source  = "mongodb/mongodbatlas"
      version = "~> 1.8"
    }
  }
}

provider "mongodbatlas" {
  private_key = local.mongodb_apikey.privateKey
  public_key  = local.mongodb_apikey.publicKey
}

but the issue remains:

╷
│ Error: Failed to query available provider packages
│ 
│ Could not retrieve the list of available versions for provider hashicorp/mongodbatlas: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/mongodbatlas
│ 
│ Did you intend to use mongodb/mongodbatlas? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on hashicorp/mongodbatlas, run the
│ following command:
│     terraform providers
manjitkumar commented 10 months ago

@omerls-pw How did you solve this for you? I am seeing the same error as shown here with same configuration.

manjitkumar commented 10 months ago
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/mongodbatlas: provider registry registry.terraform.io does not have a provider named
│ registry.terraform.io/hashicorp/mongodbatlas
│
│ Did you intend to use mongodb/mongodbatlas? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on
│ hashicorp/mongodbatlas, run the following command:
│     terraform providers

Solution which worked for me!

you must specify that (mongodb/mongodbatlas) source address in each module which requires that provider

I was using a module which was referencing mongodbatlas resources & had to add provider reference within the module itself, alongside of the caller module.

omerls-pw commented 10 months ago

@manjitkumar I don't recall but this is my current configuration:

terraform {
  required_version = "~> 1.0"

  required_providers {
    mongodbatlas = {
      source  = "mongodb/mongodbatlas"
      version = "~> 1.8"
    }
  }
}

provider "mongodbatlas" {
  private_key = local.mongodb_apikey.privateKey
  public_key  = local.mongodb_apikey.publicKey
}
Guneetgstar commented 3 weeks ago

I fixed it by adding the terraform block in the mongo module. It now looks like this:

mongo/main.tf

terraform {
  required_providers {
    mongodbatlas = {
      source  = "mongodb/mongodbatlas"
    }
  }
}

resource "mongodbatlas_project" "app_project" {
  name   = "MongoProject"
  org_id = var.mongodb_atlas_org_id
}
resource "mongodbatlas_cluster" "app_cluster" {
  name                        = "MongoDB-Atlas"
  project_id                  = mongodbatlas_project.app_project.id
  provider_instance_size_name = "M0"
  provider_name               = "AWS"
}