title: How to get public IP of azure VM from the below terraform code
body: <p>I have a terraform code which needs to retrieve public ip of a vm, here is my code</p>
  
  <pre><code># Create virtual machine
  resource "azurerm_virtual_machine" "myterraformvm" {
      name                  = "myTerraformVM"
      location              = "Central India"
      resource_group_name   = "rg-mpg-devops-poc"
      network_interface_ids = ["/subscriptions/*************/resourceGroups/rg-mpg-devops-poc/providers/Microsoft.Network/networkInterfaces/nic-mpg-devops"]
      vm_size               = "Standard_DS1_v2"
  
      storage_os_disk {
          name              = "myOsDisk"
          caching           = "ReadWrite"
          create_option     = "FromImage"
          managed_disk_type = "Premium_LRS"
      }
  
      os_profile {
          computer_name  = "myvm"
          admin_username = "azureuser"
      }
  
      os_profile_linux_config {
          disable_password_authentication = true
          ssh_keys {
              path     = "/home/azureuser/.ssh/authorized_keys"
              key_data = "ssh-rsa *********************"
          }}
       boot_diagnostics {
          enabled = "true"
          storage_uri = "https://*******.blob.core.windows.net/"
      }}
  </code></pre>
  
  <p>Here am using NIC id , which will provide public ip by default, Can some one help me on this?   </p>