Ich versuche, 2 VMs auf Azure mit Terraform zu erstellen.Zugriff auf die Ausgabe von Modul über Index
Ich erstelle 2 NICs wie
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)}"
}
}
Jetzt möchte ich sie in Modul verwenden azurerm_virtual_machine
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)}"
....
}
Das gibt mir einen Fehler
fehlgeschlagen root Config-Modul laden: Fehler beim Laden von azure/rg.tf: Fehler Lesen von Config für azurerm_virtual_machine [helloterraformvm]: azurerm_network_interface.helloterraformnic: Ressourcenvariablen müssen drei Teile: TYPE.NAME.ATTR in:
$ {element (azurerm_network_interface.helloterraformnic, count.index)}
Wie kann ich die oben erstellte verwenden können NICs mit Index?
Dank. Das hat mein Problem gelöst. – user1191140