Created
November 30, 2018 02:36
-
-
Save calum-github/866487f370bed4e6e0bf1bc2157b8a14 to your computer and use it in GitHub Desktop.
example using count in TF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# define the network interfaces in a count block for the vm's you want to assign them to | |
resource "azurerm_network_interface" "network-interface" { | |
name = "interface-number-${count.index}" | |
count = 3 | |
# ... | |
} | |
# The above resource will generate three network interfaces | |
# Now create a resource block for 3 vm's and when we get to defining the network interface id's | |
# we use element to select the interface id from the above resource block | |
resource "azurerm_virtual_machine" "foo" { | |
# ... | |
count = 3 | |
network_interface_ids = ["${element(azurerm_network_interface.network-interface.*.id, count.index)}"] | |
# ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment