我如何在本地计算机上使用Azure运行Terraform初始化

时间:2019-06-05 10:41:30

标签: azure terraform terraform-provider-azure

我正在尝试在本地运行terraform,但是它应该连接到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"

我想念什么?我想要的甚至有可能吗? 谢谢!

2 个答案:

答案 0 :(得分:0)

您需要提供Terraform连接到Azure的凭据(通常是服务主体),其中包括用户名/应用程序ID,密码和租户。阅读MS documentation,了解如何将Terraform与Azure结合使用,您会看到他们使用这些详细信息设置了环境变量。

答案 1 :(得分:0)

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