Terraform Override Files
Step-01: Introduction¶
- Terraform Override Files
- Understand and Implement about Override File Formats
- override.tf
- somefilename_override.tf
Step-02: Review Terraform Configs in terraform-manifests-v1¶
- c1-versions.tf
- c2-variables.tf
- c3-resource-group.tf
- c4-virtual-network.tf
- terraform.tfvars
Step-03: terraform-manifests-v1 - override.tf¶
- Define the same Resource Group resource with different
location
Step-04: terraform-manifests-v1 - Execute Terraform Commands¶
# Change Directory
cd terraform-manifests-v1/
# Terraform Initialize
terraform init
# Terraform Validate
terraform validate
# Terraform Plan
terraform plan
# Observation
1. Review the location for all resources.
2. Location of all resources should be "westus" because it has picked the information from "override.tf"
# Clean-Up
rm -rf .terraform*
Step-05: terraform-manifests-v2 - c3-resource-group_override.tf¶
# Resource-1: Azure Resource Group
resource "azurerm_resource_group" "myrg" {
#name = var.resource_group_name
name = "${var.business_unit}-${var.environment}-${var.resoure_group_name}"
location = "westus"
}
Step-06: terraform-manifests-v2 - Execute Terraform Commands¶
# Change Directory
cd terraform-manifests-v2/
# Terraform Initialize
terraform init
# Terraform Validate
terraform validate
# Terraform Plan
terraform plan
# Observation
1. Review the location for all resources.
2. Location of all resources should be "westus" because it has picked the information from "c3-resource-group_override.tf"
# Clean-Up
rm -rf .terraform*
Step-07: Discuss about .gitignore Terraform - Default behavior¶
- By default if we use
.gitignoreof Terraform from github it will haveoverride filesignored. - Based on need, you need to comment them in
.gitignoreif those are required and our.tffiles are checked-in to github.
🎉 New Course
Ultimate DevOps Real-World Project Implementation on AWS
$15.99
$84.99
81% OFF
MARCH2026
Enroll Now on Udemy →
🎉 Offer