title: Terraform public ip output on Azure
body: <p>I am following the example [1] to output the public IP of a new VM created on Azure with Terraform. It works fine when creating only 1 VM, but when I add a counter (default 2), it doesn't output anything.</p>
  
  <p>This is how I am modifying the .tf file:</p>
  
  <pre><code>variable "count" {
      default = "2"
  }
  ...
  
  resource "azurerm_public_ip" "test" {
    name                         = "test-pip"
    location                     = "${azurerm_resource_group.test.location}"
    resource_group_name          = "${azurerm_resource_group.test.name}"
    public_ip_address_allocation = "Dynamic"
    idle_timeout_in_minutes      = 30
  
    tags {
      environment = "test"
    }
  }
  ...
  
  data "azurerm_public_ip" "test" {
    count               = "${var.count}"
    name                = "${element(azurerm_public_ip.test.*.name, count.index)}"
    resource_group_name = "${azurerm_virtual_machine.test.resource_group_name}"
  }
  
  output "public_ip_address" {
    value = "${data.azurerm_public_ip.test.*.ip_address}"
  }
  </code></pre>
  
  <p>After terraform apply:</p>
  
  <pre><code>Outputs:
  
  public_ip_address = [
      ,
  
  ]
  </code></pre>
  
  <p>[1] <a href="https://www.terraform.io/docs/providers/azurerm/d/public_ip.html" rel="nofollow noreferrer">https://www.terraform.io/docs/providers/azurerm/d/public_ip.html</a></p>