Terraform – Modify

In our previous post, we build a resource group in Azure. Below we are going to see what happens when we modify it.

As companies grow or decrease, infrastructure constantly changes Terraform helps to manage and build these changes. Terraform update only the part of the infrastructure that changes and then holds those changes in the terraform.tfstate file.

We will modify the resource group by adding a Tag (tags are a set of data that describes and gives more information about the resource). In the below code we edit the azurerm_resource_group by adding the Tag block.

# Configure the Microsoft Azure Provider
provider "azurerm" {
      version = "~> 1.35"
 }

# Create a resource group
resource "azurerm_resource_group" "rsg" {
     name     = "ResourceGroup"
     location = "eastus"

     tags = {
        environment = "Development"
    }
 }

We run a terraform plan again and notice the ~ symbol next to the resource and tag arguments, this indicates an update in-place change. The + symbol next to environment means that tag environment will be created.

After the terraform plan we can run terraform apply to apply those changes

Leave a Reply