Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Bug azurerm_public_ip for ip_address doesn't return on first attempt #310
Unfortunately the azurerm_public_ip resource doesn't provide the IP address immediately. The only resource available is the fqdn. This is only good if this assumes that the workstation that terraform is running on has access to a DNS server. The issue here is that the operator cannot use the ip_address of the azurerm_public_ip resource in the same
$ terraform state show azurerm_public_ip.master_public_ip id = /subscriptions/<sub_id>/resourceGroups/deleteme-test/providers/Microsoft.Network/publicIPAddresses/pub-ip-1 domain_name_label = noder-1 fqdn = node-1-1231414124.westus.cloudapp.azure.com location = westus name = pub-ip-1 public_ip_address_allocation = dynamic resource_group_name = deleteme-test
$ terraform refresh
$ terraform state show azurerm_public_ip.master_public_ip id = /subscriptions/<sub_id>/resourceGroups/deleteme-test/providers/Microsoft.Network/publicIPAddresses/pub-ip-1 domain_name_label = noder-1 fqdn = node-1-1231414124.westus.cloudapp.azure.com ip_address = 184.108.40.206 location = westus name = pub-ip-1 public_ip_address_allocation = dynamic resource_group_name = deleteme-test
Thanks for opening this issue :)
Unfortunately the underlying Azure infrastructure won't allocate an IP Address to a Dynamic Public IP until it's assigned to a resource in that's running (such as a VM / LB etc) - whereas Static Public IP's will be returned a value even prior to being assigned to something.
That said, you should be able to work around this by using the
Would it be possible for you to take a look and let me know if that solves your issue?
Thanks for your suggestion. I just tried it on my end and it has the same result as before. It only provides the IP address after a
$ terraform apply $ terraform console > data.azurerm_public_ip.master_public_ip.*.ip_address Resource 'data.azurerm_public_ip.master_public_ip' does not have attribute 'ip_address' for variable 'data.azurerm_public_ip.master_public_ip.*.ip_address' > $ terraform refresh $ terraform console > data.azurerm_public_ip.master_public_ip.*.ip_address [ 220.127.116.11, 18.104.22.168, 22.214.171.124 ]
Apologies for the delay in responding to this issue.
Taking a look at the previous configuration I posted - I noticed I missed out the
which outputs the value:
As the Public IP address isn't available until the VM starts the
That said - given this functionality is working as designed by Azure (and documented to say as such in the Terraform documentation) - I'm going to close this issue for the moment.
referenced this issue
Jan 28, 2018
@genevievelesperance theres gotta be some wonky lack of parity in their implementation, because getting the ip via the data workaround worked for me. exactly as above: