本文介绍了在Azure Pipeline中运行的Terraform尝试安装azcli提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm running Terraform in an Azure Pipeline (something I have experience of doing) and for some reason the init step is attempting to install a provider for azcli, which I don't think exists. This does not happen when I run Terraform on my local machine.

我的提供商文件为:

terraform {
  required_version = ">=0.13"

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

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

这是我看到的错误:

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

I'm not sure why Terraform is trying to install the azcli provider; I don't think it even exists. Has anyone seen this before?

推荐答案

Terraform 在初始化时直接或间接搜索提供者.资源名称或提供程序定义中可能有错误.在代码库中搜索azcli.

Terraform searches directly and indirectly for providers when initialization. It is possible there is a mistake in the resource name or provider definition. Search your codebase for 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

这篇关于在Azure Pipeline中运行的Terraform尝试安装azcli提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 03:48