Create a Public IP Address in Azure With Terraform

In this blog post I wil show you how to create a Public IP address in Microsoft Azure using Terraform code.

This post follows our Terraform covrage, so please visit the Terraform category page for more Terrafom posts.

Configuration

The following configuration is using the latest Azure Terraform provider and I’m also creatign a new resource group for the public IP address.

The name of the public IP address is pubipazure and the last configuration block adds a Tag.

terraform {
   required_providers {
     azurerm = {
       source = "hashicorp/azurerm"
       version = ">= 2.41"
     }
   }
 }
 provider "azurerm" {
   features {}
 }
 resource "azurerm_resource_group" "rg" {
   name     = "trdemo"
   location = "australiasoutheast"
 }
 resource "azurerm_public_ip" "pubip" { 
   name                         = "pubipazure"
   location                     = "australiasoutheast"
   resource_group_name          = azurerm_resource_group.rg.name 
   allocation_method = "Static"
 tags = {
     environment = "Dev"
   }
   }