Error: 无法查询可用的提供者包

huangapple go评论72阅读模式
英文:

Error: Failed to query available provider packages

问题

I'm trying to run AKS using terraform(version: 1.4.6) and when I'm performing "terraform init" getting an issue and below is the screenshot for reference.
if anyone knows Kindly help on this.

Modules: AKS, KeyVault, Service Principal

Error: 无法查询可用的提供者包

Error: 无法查询可用的提供者包

英文:

i'm trying to run AKS using terraform(version: 1.4.6) and when i'm performing "terraform init" getting an issues and below is the screen shot for ref.
if any one knows Kindly help on this.

Modules: AKS, KeyVault, Service Principal

Error: 无法查询可用的提供者包

Error: 无法查询可用的提供者包

答案1

得分: 1

You are defining the required_providers block in a wrong way. This:

terraform {

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

  }
}

has to be re-written. You have to use the proper syntax as defined in the documentation. So this would be something like:

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

You don't have to define the random provider like that. Running terraform init works as expected:

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.

  [1]: https://github.com/piyushsachdeva/Terraform_AKS/blob/master/versions.tf
  [2]: https://developer.hashicorp.com/terraform/language/providers/requirements#requiring-providers

<details>
<summary>英文:</summary>

You are defining the [`required_providers` block][1] in a wrong way. This:

```hcl
terraform {

  required_providers {
    azuread = &quot;~&gt; 2.9.0&quot;
    random  = &quot;~&gt; 3.1&quot;
    azurerm = &quot;~&gt; 3.0.0&quot;

  }
}

has to be re-written. You have to use the proper syntax as defined in the documentation. So this would be something like:

terraform {
  required_providers {
    azurerm = {
      source  = &quot;hashicorp/azurerm&quot;
      version = &quot;~&gt; 3.0&quot;
    }
    azuread = {
      source  = &quot;hashicorp/azuread&quot;
      version = &quot;~&gt; 2.0&quot;
    }
  }
}

You don't have to define the random provider like that. Running terraform init works as expected:

terraform init           
Initializing modules...
Initializing the backend...
Initializing provider plugins...
- Finding hashicorp/azuread versions matching &quot;~&gt; 2.0&quot;...
- Finding hashicorp/azurerm versions matching &quot;~&gt; 3.0&quot;...
- 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 &quot;terraform init&quot; in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running &quot;terraform plan&quot; 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.

huangapple
  • 本文由 发表于 2023年5月11日 20:10:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76227523.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定