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

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

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:

  1. terraform {
  2. required_providers {
  3. azuread = "~> 2.9.0"
  4. random = "~> 3.1"
  5. azurerm = "~> 3.0.0"
  6. }
  7. }

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

  1. terraform {
  2. required_providers {
  3. azurerm = {
  4. source = "hashicorp/azurerm"
  5. version = "~> 3.0"
  6. }
  7. azuread = {
  8. source = "hashicorp/azuread"
  9. version = "~> 2.0"
  10. }
  11. }
  12. }

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

  1. terraform init
  2. Initializing modules...
  3. Initializing the backend...
  4. Initializing provider plugins...
  5. - Finding hashicorp/azuread versions matching "~> 2.0"...
  6. - Finding hashicorp/azurerm versions matching "~> 3.0"...
  7. - Installing hashicorp/azurerm v3.55.0...
  8. - Installed hashicorp/azurerm v3.55.0 (signed by HashiCorp)
  9. - Installing hashicorp/azuread v2.38.0...
  10. - Installed hashicorp/azuread v2.38.0 (signed by HashiCorp)
  11. Terraform has created a lock file .terraform.lock.hcl to record the provider
  12. selections it made above. Include this file in your version control repository
  13. so that Terraform can guarantee to make the same selections by default when
  14. you run "terraform init" in the future.
  15. Terraform has been successfully initialized!
  16. You may now begin working with Terraform. Try running "terraform plan" to see
  17. any changes that are required for your infrastructure. All Terraform commands
  18. should now work.
  19. If you ever set or change modules or backend configuration for Terraform,
  20. rerun this command to reinitialize your working directory. If you forget, other
  21. commands will detect it and remind you to do so if necessary.
  22. [1]: https://github.com/piyushsachdeva/Terraform_AKS/blob/master/versions.tf
  23. [2]: https://developer.hashicorp.com/terraform/language/providers/requirements#requiring-providers
  24. <details>
  25. <summary>英文:</summary>
  26. You are defining the [`required_providers` block][1] in a wrong way. This:
  27. ```hcl
  28. terraform {
  29. required_providers {
  30. azuread = &quot;~&gt; 2.9.0&quot;
  31. random = &quot;~&gt; 3.1&quot;
  32. azurerm = &quot;~&gt; 3.0.0&quot;
  33. }
  34. }

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

  1. terraform {
  2. required_providers {
  3. azurerm = {
  4. source = &quot;hashicorp/azurerm&quot;
  5. version = &quot;~&gt; 3.0&quot;
  6. }
  7. azuread = {
  8. source = &quot;hashicorp/azuread&quot;
  9. version = &quot;~&gt; 2.0&quot;
  10. }
  11. }
  12. }

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

  1. terraform init
  2. Initializing modules...
  3. Initializing the backend...
  4. Initializing provider plugins...
  5. - Finding hashicorp/azuread versions matching &quot;~&gt; 2.0&quot;...
  6. - Finding hashicorp/azurerm versions matching &quot;~&gt; 3.0&quot;...
  7. - Installing hashicorp/azurerm v3.55.0...
  8. - Installed hashicorp/azurerm v3.55.0 (signed by HashiCorp)
  9. - Installing hashicorp/azuread v2.38.0...
  10. - Installed hashicorp/azuread v2.38.0 (signed by HashiCorp)
  11. Terraform has created a lock file .terraform.lock.hcl to record the provider
  12. selections it made above. Include this file in your version control repository
  13. so that Terraform can guarantee to make the same selections by default when
  14. you run &quot;terraform init&quot; in the future.
  15. Terraform has been successfully initialized!
  16. You may now begin working with Terraform. Try running &quot;terraform plan&quot; to see
  17. any changes that are required for your infrastructure. All Terraform commands
  18. should now work.
  19. If you ever set or change modules or backend configuration for Terraform,
  20. rerun this command to reinitialize your working directory. If you forget, other
  21. 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:

确定