Output Azure Virtual Machine Public IP With Terraform

When deploying Windows or Linux Virtual Machines to Microsoft Azure, we could use Terraform to output the VM IP address.

This post will show how to output the public IP address of a deployed Azure VM.

Terraform Output

The following code will output the public IP of a Microsoft Azure virtual machine after the deployment is completed.

 output "VM-IP" {
     description = "The VM Public IP is:"
     value = azurerm_public_ip.vm1publicip.ip_address
 }    

To use the code, change the vm1publicip to the name of your public IP address. Copy the code either in your main .tf file or your outputs.tf file.

Note: In some cases, you might need to run Terraform apply again to display the IP address.


Posted

in

,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.