繁体   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