【问题标题】:How can I run terraform init with azure on my local machine如何在本地计算机上使用 azure 运行 terraform init
【发布时间】:2019-06-05 21:39:05
【问题描述】:

我正在尝试在本地运行 terraform,但它应该连接到 azure 机器。我们有 azure 代理可以做到这一点。如果我在本地运行它,它将帮助我更快地移动。

这是我的命令

terraform init -reconfigure -backend-config ~/common.tfvars

这是错误

    Initializing modules...                                                                                                                                                                                                                │··················································
    - module.kubernetes                                                                                                                                                                                                                    │··················································
    - module.database                                                                                                                                                                                                                      │··················································
    - module.trafficmanager                                                                                                                                                                                                                │··················································
    - module.appInsights                                                                                                                                                                                                                   │··················································
                                                                                                                                                                                                                                        │··················································
    Initializing the backend...                                                                                                                                                                                                            │··················································
                                                                                                                                                                                                                                        │··················································
    Error configuring the backend "azurerm": resource_group_name and credentials must be provided when access_key is absent                                                                                                                │··················································
                                                                                                                                                                                                                                        │··················································
    Please update the configuration in your Terraform files to fix this error                                                                                                                                                              │··················································
    then run this command again.  

猫 ~/common.tfvars

    resource_group_name = "myproject-nst-config-RG"
    storage_account_name = "myprojectnstterraform"
    container_name       = "tfstatemyprojectact"
    key                  = "nstproject"

我错过了什么?我想要的甚至可能吗? 谢谢!

【问题讨论】:

    标签: azure terraform terraform-provider-azure


    【解决方案1】:

    您需要提供 Terraform 连接到 Azure 的凭据,通常是服务主体,这将包括用户名/应用程序 ID、密码和租户。阅读MS documentation on using Terraform with Azure,您会看到他们使用这些详细信息设置环境变量。

    【讨论】:

    • 如果服务主体对该存储没有权限,则传递存储帐户密钥 (access_key)
    【解决方案2】:

    如果您尝试使用 az cli 登录,则需要确保您运行的是 Terraform 0.12。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多