title: How to interpolate COUNT in Terraform?
body: <p>I am creating a number of VMs in Azure with corrosponding NICs and PublicIPs.</p>
  
  <p>I can create unique names for the VMs no problem:</p>
  
  <pre><code>resource "azurerm_virtual_machine" "workernode" {
      count = "${var.nodeCount}"
      name = "workernode-${count.index +1}"
  </code></pre>
  
  <p>and the public IPs:</p>
  
  <pre><code>resource "azurerm_public_ip" "AliasworkerPubIP" {
      count = "${var.nodeCount}"
      name = "workerpubip${count.index +1}"
  </code></pre>
  
  <p>and the NIC:</p>
  
  <pre><code>resource "azurerm_network_interface" "workerNIC" {
      count = "${var.nodeCount}"
      name = "workerNIC.${count.index +1}"  
  </code></pre>
  
  <p>but I cant work out how to get it to work for then connecting the NIC to the PublicIP just created ...</p>
  
  <p>Have tried various different ways and nothing is clicking ... I know I missing something or not understanding interpolation parsing correctly, but what?!</p>
  
  <p>examples I have tried:</p>
  
  <pre><code>public_ip_address_id = "${azurerm_public_ip}.${format("Alias_WorkerIP%d.id", count.index +1)}" 
  
  public_ip_address_id = "${format("Alias_WorkerIP%d.id", count.index +1)}"
  
  public_ip_address_id = "${format("azurerm_public_ip.workerpubip.%s.id", count.index +1)}" 
  </code></pre>
  
  <p>any ideas of where I am going wrong?</p>