Terraform Command Basics
Step-01: Introduction¶
- Understand basic Terraform Commands
- terraform init
- terraform validate
- terraform plan
- terraform apply
- terraform destroy
Step-02: Review terraform manifests¶
- Pre-Conditions-1: Get Azure Regions and decide the region where you want to create resources
- Pre-Conditions-2: If not done earlier, complete
az loginvia Azure CLI. We are going to use Azure CLI Authentication for Terraform when we use Terraform Commands. - Azure Regions
- Azure Regions Detailed
# Terraform Settings Block terraform { required_version = ">= 1.0.0" required_providers { azurerm = { source = "hashicorp/azurerm" version = ">= 2.0" # Optional but recommended in production } } } # Configure the Microsoft Azure Provider provider "azurerm" { features {} } # Create Resource Group resource "azurerm_resource_group" "my_demo_rg1" { location = "eastus" name = "my-demo-rg1" }
Step-03: Terraform Core Commands¶
# Terraform Initialize
terraform init
# Terraform Validate
terraform validate
# Terraform Plan to Verify what it is going to create / update / destroy
terraform plan
# Terraform Apply to Create Resources
terraform apply
Step-04: Verify Azure Resource Group in Azure Management Console¶
- Go to Azure Management Console -> Resource Groups
- Verify newly created Resource Group
- Review
terraform.tfstatefile
Step-05: Destroy Infrastructure¶
# Destroy Azure Resource Group
terraform destroy
Observation:
1. Verify if the resource group got deleted in Azure Management Console
2. Verify terraform.tfstate file and resource group info should be removed
3. Verify terraform.tfstate.backup, it should have the resource group info here stored as backup.
# Delete Terraform files
rm -rf .terraform*
rm -rf terraform.tfstate*
Step-08: Conclusion¶
- Re-iterate what we have learned in this section
- Learned about Important Terraform Commands
- terraform init
- terraform validate
- terraform plan
- terraform apply
- terraform destroy
🎉 New Course
Ultimate DevOps Real-World Project Implementation on AWS
$15.99
$84.99
81% OFF
MARCH2026
Enroll Now on Udemy →
🎉 Offer

