将变量从ARM模板传递到Terraform

时间:2020-09-29 19:03:03

标签: azure terraform arm-template terraform-provider-azure

我想将输出从ARM模板传递到Terraform。 输出ARM

        "logicAppUrl": {
             "type": "string",
            "value": "[parameters('workflows_adf_sb_ml_name')]"
         } 
    }

输出地形

resource "azurerm_template_deployment" "adf-sb-ml" {
  name                = "adf-sb-ml"
  resource_group_name = var.rg

  depends_on = [
    null_resource.config
  ]

  template_body = file("upload_files/adf-sb-ml.json")

  parameters = {
    "connections_servicebus_name" = "servicebus"
    "workflows_adf_sb_ml_name" = "adf-sb-ml"

  }

  deployment_mode = "Incremental"

}

output "appid" {
  value = "${lookup(azurerm_template_deployment.adf-sb-ml.outputs, "logicAppUrl")}"
}

但是我运行代码时出错

在输出“ appid”中:2020-09-29T18:40:40.8713191Z 2:值= “ $ {[4mlookup([0mazurerm_template_deployment.adf-sb-ml.outputs, “ logicAppUrl”)}“ 2020-09-29T18:40:40.8713804Z [0m
[90m | ---------------- [0m 2020-09-29T18:40:40.8714398Z [0m
[90m | [0m [1mazurerm_template_deployment.adf-sb-ml.outputs [0m是 字符串[0m 2020-09-29T18:40:40.8714829Z [0m 2020-09-29T18:40:40.8715289Z调用函数“查找”失败:查找 找不到'logicAppUrl'。

1 个答案:

答案 0 :(得分:0)

我对您的代码进行了简短测试,它可以正常工作。它应该可以工作,或者您可以检查ARM模板是否可以在不包含Terraform的情况下单独部署,也可以将terraform提供商升级到最新版本。

enter image description here