Terraform Meta-Argument lifecycle ignore_changes
Step-01: Introduction¶
- lifecyle Meta-Argument block contains 3 arguments
- create_before_destroy
- prevent_destroy
- ignore_changes
- We are going to practically understand and implement
ignore_changes
Step-02: Review Terraform Manifests¶
- c1-versions.tf
- c2-resource-group.tf
- c3-virtual-network.tf
Step-03: Create a Azure Virtual Network, make manual changes and understand the behavior¶
- Create Azure Virtual Network
Step-04: Update the tag by going to Azure management console¶
- Add a new tag manually to Azure Virtual Network Resource
- Try
terraform applynow - Terraform will find the difference in configuration on remote side when compare to local and tries to remove the manual change when we execute
terraform apply
Step-05: Add the lifecyle - ignore_changes block¶
- Enable the block in
c3-virtual-network.tf - Add new tags manually using Azure Management console for Azure Virtual Network Resource
Step-06: Lets see the downside of this Lifecycle Block¶
- Add new tag from Terraform Configs by editing the
c3-virtual-network.tf# Terraform Plan terraform plan Observation: 1. "No changes" will be reported as we cannot add new tag because it is present in ignore_changes lifecycle block # Terraform Apply terraform apply Observation: 1. "No changes" will be reported as we cannot add new tag because it is present in ignore_changes lifecycle block
Step-07: Clean-Up¶
# Destroy Resource
terraform destroy -auto-approve
# Clean-Up
rm -rf .terraform*
rm -rf terraform.tfstate*
References¶
🎉 New Course
Ultimate DevOps Real-World Project Implementation on AWS
$15.99
$84.99
81% OFF
MARCH2026
Enroll Now on Udemy →
🎉 Offer