私はTerraformを使用してAzureで2つのVMを作成しようとしています。インデックスからモジュールの出力にアクセスする
私は
variable "internalips" {
description = "List of Internal IPs"
default = ["10.0.2.10", "10.0.2.11"]
type = "list"
}
resource "azurerm_network_interface" "helloterraformnic" {
count = 2
name = "nic-${count.index}"
location = "West US"
resource_group_name = "myrg"
ip_configuration {
name = "testconfiguration1"
subnet_id = "${azurerm_subnet.helloterraformsubnet.id}"
private_ip_address_allocation = "static"
private_ip_address = "${element(private_ip_address, count.index)}"
}
}
のような2枚のNIC今、私はこれは私にエラー
を与える
resource "azurerm_virtual_machine" "helloterraformvm" { count = 2 name = "${element(elasticmachines, count.index)}" location = "West US" resource_group_name = "myrg" network_interface_ids = "${element(azurerm_network_interface.helloterraformnic, count.index)}" .... }
azurerm_virtual_machineモジュールでそれらを使用するには、ルート設定モジュールをロードできませんでした作成します。 azurerm_virtual_machine [helloterraformvm]の設定を読み込んでいる間にエラー が読み込まれました: azurerm_network_interface.helloterraformnic: 三つの部分でなければならないリソース変数:
$ {要素(azurerm_network_interface.helloterraformnic、count.index)}私が作成した上記を使用するにはどうすればよい
:中TYPE.NAME.ATTR NICはインデックスを使用していますか?
感謝を。それが私の問題を解決しました。 – user1191140