簡體   English   中英

盡管是訂閱所有者,但無法使用 terraform 創建 azura 資源

[英]Unable to create azura resources using terraform despite being a subscription owner

我無法使用 terraform 在 azure 雲中創建任何資源。

WSL2-Ubuntu:

             Ubuntu 20.04.3 LTS 

Terraform 版本:

             Terraform v1.1.5

AZ CLI 版本:

            "azure-cli": "2.33.0"
            "azure-cli-core": "2.33.0"
            "azure-cli-telemetry": "1.0.6"

一開始我通過 az 登錄登錄到 azure 訂閱。 我在這個帳戶上只有一個可用的訂閱並且我是所有者。

然后我創建與此處相同的“main.tf”文件: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs#example-usage

在“terraform init”之后我做了“terraform plan”但是我收到了那個錯誤:

                     Error: Unable to list provider registration status, it is possible that this is due to invalid credentials or the service principal does not have permission to use the Resource Manager API, Azure error: resources.ProvidersClient#List: Failure sending request: StatusCode=0 -- Original Error: Get "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers?api-version=2016-02-01": dial tcp: lookup management.azure.com on 000.00.000.0:00: cannot unmarshal DNS message

                     with provider["registry.terraform.io/hashicorp/azurerm"],
                     on main.tf line 10, in provider "azurerm":
                     10: provider "azurerm" {

我也是 go 通過這種方式: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/service_principal_client_secret

我的應用程序在訂閱級別具有貢獻者/所有者權限。

然后添加這個配置:

            provider "azurerm" {
               features {}
               subscription_id = "00000000-0000-0000-0000-000000000000"
               client_id       = "00000000-0000-0000-0000-000000000000"
               client_secret   = var.client_secret
               tenant_id       = "00000000-0000-0000-0000-000000000000"
            }

最后我得到了同樣的錯誤。 你有什么想法?

sudo vim /etc/resolv.conf

並將nameserver值更改為8.8.8.8

它應該可以工作,但每次重新啟動時都應該執行此操作或編寫腳本來自動執行它!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM