【发布时间】:2021-09-18 06:58:09
【问题描述】:
由于以下错误,我无法初始化或销毁。我找不到对过时提供程序的引用。
无法检索提供程序 hashcorp/azure 的可用版本列表:提供程序注册表 registry.terraform.io 没有名为 registry.terraform.io/hashicorp/azure 的提供程序
我想弄清楚为什么 terraform 需要使用 hashcorp/azure。
我正在使用 terraform 0.15.0,并且也在 1.0.1 上尝试过
我没有使用任何子模块或自定义模块。我有一个基本的扁平结构。
我认为旧的提供程序已经使用了一段时间,然后因为已被弃用而被撤消。我似乎找不到删除该引用的方法。
providers 命令显示远程状态不需要它。
➜ terraform init
Initializing the backend...
Initializing provider plugins...
- Reusing previous version of hashicorp/azurerm from the dependency lock file
- Reusing previous version of mongodb/mongodbatlas from the dependency lock file
- Finding latest version of hashicorp/azure...
- Using previously-installed hashicorp/azurerm v2.59.0
- Using previously-installed mongodb/mongodbatlas v0.9.1
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/azure: provider registry registry.terraform.io does not have a provider named
│ registry.terraform.io/hashicorp/azure
│
│ Did you intend to use terraform-providers/azure? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on
│ hashicorp/azure, run the following command:
│ terraform providers
╵
我没有使用任何自定义或子模块,只是一个平面文件夹结构。
这是 terraform 提供程序的输出:
➜ terraform providers
Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/azurerm] 2.59.0
├── provider[registry.terraform.io/mongodb/mongodbatlas] 0.9.1
└── provider[registry.terraform.io/hashicorp/azure]
Providers required by state:
provider[registry.terraform.io/hashicorp/azurerm]
这是我的 main.tf:
#base assets required to connect to cloud provider
# Define Terraform provider
terraform {
required_version = ">= 0.13"
backend "azurerm" {
resource_group_name = "REDACTED"
storage_account_name = "REDACTED"
container_name = "tfbackend"
key = "terraform.state"
}
required_providers { #what does this mean and why is it required.
mongodbatlas = {
source = "mongodb/mongodbatlas"
version = "0.9.1"
}
azurerm = {
source = "hashicorp/azurerm"
version = "2.59.0"
}
}
}
provider "azurerm" {
features {}
subscription_id = var.subscription_id
client_id = var.service_principal_app_Id
client_secret = var.service_principal_password
tenant_id = var.tenant_id
}
provider "mongodbatlas" {
public_key = var.mongodb_atlas_api_pub_key
private_key = var.mongodb_atlas_api_pri_key
}
locals {
infra_version = "1.0"
}
【问题讨论】:
标签: terraform terraform-provider-azure