【问题标题】:Terraform reports error "Failed to query available provider packages"Terraform 报告错误“无法查询可用的提供程序包”
【发布时间】:2021-06-02 14:52:09
【问题描述】:

我已经为 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 

你知道出了什么问题吗?

【问题讨论】:

标签: terraform terraform-provider-azure


【解决方案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 升级指南中还有一些上述未解决的其他注意事项,因此如果您在尝试上面显示的内容后看到不同的错误消息,您可能仍需要执行该升级指南中描述的步骤。

【讨论】:

  • 抱歉,我没有更改 TF 版本。我一定会试试你的建议。非常感谢!
  • 感谢您的帮助!友情提示:你在monogdb/mongodbatlas中有错字应该是:source = "mongodb/mongodbatlas"
猜你喜欢
  • 1970-01-01
  • 2021-08-26
  • 2022-08-09
  • 1970-01-01
  • 1970-01-01
  • 2021-12-28
  • 1970-01-01
  • 2020-02-11
  • 1970-01-01
相关资源
最近更新 更多