在Azure Pipeline中运行的Terraform尝试安装azcli提供程序

时间:2020-10-23 13:49:26

标签: azure-devops terraform azure-pipelines terraform-provider-azure

我正在Azure管道中运行Terraform(我有做过的事情),由于某种原因,初始化步骤正在尝试为azcli安装提供程序,但我认为该提供程序不存在。当我在本地计算机上运行Terraform时,不会发生这种情况。

我的提供商文件为:

terraform {
  required_version = ">=0.13"

 backend "azurerm" {
   container_name = "tfstate"
   key            = "terraform.tfstate"
 }

 required_providers {
   grafana = {
   source  = "grafana/grafana"
   version = "=1.5.0"
   }
  }
}

这是我看到的错误:

Terraform init error

我不确定Terraform为什么要尝试安装azcli提供程序;为什么?我认为它甚至不存在。有人看过吗?

1 个答案:

答案 0 :(得分:0)

初始化时为提供者使用

Terraform searches directly and indirectly。资源名称或提供程序定义中可能有错误。在代码库中搜索azcli。

▶ cat .\main.tf
resource "azcli_test" "test" {
    test = "true"
}

~\projects\test\t5                                                                                                                            ◷ 10:10:21 AM
▶ C:\Users\pearcec\bin\terraform init

Initializing the backend...

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

Error: Failed to install provider

Error while installing hashicorp/azcli: provider registry
registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/azcli

~\projects\test\t5                                                                                                                            ◷ 10:10:23 AM
▶ cat .\main.tf
provider "azcli" {
  features {}
}

~\projects\test\t5                                                                                                                            ◷ 10:13:41 AM
▶ C:\Users\pearcec\bin\terraform init

Initializing the backend...

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

Error: Failed to install provider

Error while installing hashicorp/azcli: provider registry
registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/azcli

▶ cat .\main.tf
terraform {
  required_providers {
    azcli = {
      source  = "-/azcli"
    }
  }
}

~\projects\test\t5                                                                                                                            ◷ 10:16:09 AM
▶ C:\Users\pearcec\bin\terraform init

Initializing the backend...

Initializing provider plugins...
- Finding latest version of -/azcli...

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider -/azcli:
provider registry registry.terraform.io does not have a provider named
registry.terraform.io/-/azcli