azure 错误:无法查询可用的提供程序包

5hcedyr0  于 2023-05-18  发布在  其他
关注(0)|答案(1)|浏览(106)

我正在尝试使用terraform运行AKS(版本:1.4.6),当我执行“terraform init”得到一个问题,下面是屏幕截图参考.如果有人知道的话,请帮忙。
模块:AKS,KeyVault,Service Principal

1zmg4dgp

1zmg4dgp1#

你用错误的方式定义required_providers block。这一点:

terraform {

  required_providers {
    azuread = "~> 2.9.0"
    random  = "~> 3.1"
    azurerm = "~> 3.0.0"

  }
}

必须重写。您必须使用文档中定义的正确语法。所以这应该是这样的:

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 3.0"
    }
    azuread = {
      source  = "hashicorp/azuread"
      version = "~> 2.0"
    }
  }
}

您不必这样定义random提供程序。运行terraform init按预期运行:

terraform init           
Initializing modules...

Initializing the backend...

Initializing provider plugins...
- Finding hashicorp/azuread versions matching "~> 2.0"...
- Finding hashicorp/azurerm versions matching "~> 3.0"...
- Installing hashicorp/azurerm v3.55.0...
- Installed hashicorp/azurerm v3.55.0 (signed by HashiCorp)
- Installing hashicorp/azuread v2.38.0...
- Installed hashicorp/azuread v2.38.0 (signed by HashiCorp)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

相关问题