How to Output Azure Terraform Deployment Data

In this blog post, I will show you how I output deployment data from Azure using Terraform after deploying resources.

In the example that you will see, I will create a Public IP on Microsoft Azure using the code I used last week to deploy an IP and add the output code to it.

Output Block

To output information about deployments, Terraform uses the Output configuration block. This block is very handy because it allows us to retrieve information. In our case, I will use it to output the IP address on the public IP address after creating it.

Terraform Configuration

The code below, will create an IP address and output the address to the screen. to test copy and run.

terraform {
   required_providers {
     azurerm = {
       source = "hashicorp/azurerm"
       version = ">= 2.43"
     }
   }
 }
 provider "azurerm" {
   features {}
 }
 resource "azurerm_resource_group" "rg" {
   name     = "trdemo"
   location = "australiasoutheast"
 }
 resource "azurerm_public_ip" "pubip" { 
   name                         = "bubipazure"
   location                     = "australiasoutheast"
   resource_group_name          = azurerm_resource_group.rg.name 
   allocation_method = "Static"
 tags = {
     environment = "Dev"
   }
 }
 output "ipaddres" {
      description = "The Public IP address is:"
      value = azurerm_public_ip.pubip.ip_address
       }

Leave a comment

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.