【发布时间】:2020-11-20 15:40:59
【问题描述】:
我正在学习开发一个 terraform 提供程序。我正在关注 hashcorp 整理的这个惊人的教程:https://learn.hashicorp.com/tutorials/terraform/provider-use?in=terraform/providers#create-order
Terraform init 在我添加 required_providers 块时起作用。但是,一旦我添加了资源并执行terraform apply,应用失败并出现“无法加载插件”错误。在此错误之后,当我运行 terraform providers 进行调试时,它会将提供程序和资源列为必需的提供程序。
我正在使用的 Terraform 版本:0.13.5
下面是我使用的代码:
required_providers {
hashicups = {
versions = ["0.3"]
source = "hashicorp.com/edu/hashicups"
}
}
}
resource "haschicups_order" "edu" {
items {
coffee {
id = 3
}
quantity = 2
}
items {
coffee {
id = 2
}
quantity = 2
}
}
output "edu_order" {
value = haschicups_order.edu
}```
```% terraform providers
Providers required by configuration:
.
├── provider[hashicorp.com/edu/hashicups]
└── provider[registry.terraform.io/hashicorp/haschicups]```
【问题讨论】:
-
从历史上看,
terraform providers子命令确实被本地构建和加载的提供程序弄糊涂了。这种行为似乎仍然存在。 -
“无法加载插件”的 Terraform 错误,给出的原因是“配置提供了无法定位的所需插件,不满足版本约束”。我确信这个错误引用了 terraform 作为提供者令人困惑的资源