将变量从json文件传递到Azure模块

时间:2018-06-26 07:38:10

标签: azure terraform

我已经生成了一个json文件,其中包含我想作为参数传递给Azure中模块的变量。

  1. JSON文件-test.json
{
    "ad": {
        "NumInstances": "1",
        "VMSize": "Standard_F2"
    }
}
  1. Main.tf
resource "azurerm_virtual_machine" "service_name" {
  count                 = "<What goes here?>"
  name                  = "${var.service_name}-${count.index}"
  location              = "${azurerm_resource_group.service_name.location}"
  resource_group_name   = "${azurerm_resource_group.service_name.name}"
  network_interface_ids = ["${element(azurerm_network_interface.service_name.*.id, count.index)}"]
  vm_size               = "<What goes here?>"
  availability_set_id   = "${var.num_instances == 1 ? "" : "${azurerm_availability_set.service_name.id}"
}

这是如何实现的?

0 个答案:

没有答案