Terraform 报告错误“无法查询可用的提供程序包”

时间:2021-06-02 14:52:09

标签: terraform terraform-provider-azure

我已经为 Mongodb terraform 模块创建了如下的 main.tf 文件。

resource "mongodbatlas_teams" "test" {
  org_id     = null
  name       = "MVPAdmin_Team"
  usernames  = ["user1@email.com", "user2@email.com", "user3@email.com"]
}

resource "mongodbatlas_project" "test" {
  name   = "MVP_Project"
  org_id = null

  teams {
    team_id    = null
    role_names = ["GROUP_CLUSTER_MANAGER"]

  }
  
}
resource "mongodbatlas_project_ip_access_list" "test" {
  project_id = null
  ip_address = null
  comment    = "IP address for MVP Dev cluster testing"
}

resource "mongodbatlas_cluster" "test" {
  name                = "MVP_DevCluster"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  cluster_type        = REPLICASET
  state_name          = var.state_name
  replication specs {
     num_shards= var.num_shards
     region_config {
       region_name = "AU-EA"
       electable_nodes = var.electable_nodes
       priority        = var.priority
       read_only_nodes = var.read_only_nodes
     }  
  }

  provider_backup_enabled = var.provider_backup_enabled
  auto_scaling_disk_gb_enabled = var.auto_scaling_disk_gb_enabled
  mongo_db_major_version = var.mongo_db_major_version
  provider_name = "Azure"
  provider_disk_type_name = var.provider_disk_type_name
  provider_instance_size_name = var.provider_instance_size_name



  mongodbatlas_database_user {
    username = var.username
    password = var.password
    auth_database_name = var.auth_database_name
    role_name = var.role_name
    database_name = var.database_name
  }
  mongodbatlas_database_snapshot_backup_policy {
    policy_item = var.policy_item
    frequency_type = var.frequency_type
    retention_value = var.retention_value
  
 }

 advanced_configuration {
      minimum_enabled_tls_protocol = var.minimum_enabled_tls_protocol
   no_table_scan                  = var.no_table_scan
   connection_string              = var.connection_string

 } 
}

但是,terraform init 报告如下:

$ terraform init

Initializing the backend...

Initializing provider plugins...
- Finding latest version of hashicorp/mongodbatlas...

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

If you have just upgraded directly from Terraform v0.12 to Terraform v0.14
then please upgrade to Terraform v0.13 first and follow the upgrade guide for
that release, which might help you address this problem.

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 

知道出了什么问题吗?

1 个答案:

答案 0 :(得分:1)

错误消息解释了看到此错误消息的最可能原因:您已直接从 Terraform v0.12 升级到 Terraform v0.14,而没有运行 the Terraform v0.13 upgrade steps

如果您先升级到 Terraform v0.13 并按照这些说明进行操作,那么升级工具应该能够提供有关此处更改内容的更具体说明,甚至可能会自动为您升级配置。

但是,如果您愿意,您也可以手动添加 v0.13 升级工具将插入的配置块,以指定您打算在此模块中将 mongodb/mongodbatlas 提供程序用作“mongodbatlas” :

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

v0.13 升级指南中还有一些其他注意事项,上面没有解决,因此,如果在尝试我上面显示的内容后看到不同的错误消息,您可能仍需要执行该升级指南中描述的步骤。< /p>