Developed by HashiCorp, Terraform is the undisputed industry standard tool for building, changing, and versioning cloud infrastructure safely and efficiently. Unlike vendor-locked tools (such as CloudFormation for AWS or ARM/Bicep for Azure), Terraform is cloud-agnostic, allowing engineers to manage AWS, Azure, Google Cloud, Cloudflare, GitHub, and Kubernetes clusters using a unified declarative syntax called HashiCorp Configuration Language (HCL).
terraform init: Initializes the working directory containing Terraform configuration files. Downloads necessary cloud provider plugins (e.g., hashicorp/aws) and configures the remote backend.terraform plan: Reads the current state file, refreshes live cloud infrastructure via APIs, calculates the difference (diff), and generates an execution plan outlining exactly what will be created (+), modified (~), or destroyed (-).terraform apply: Prompts for human confirmation, then executes the planned API calls against the cloud provider in the correct dependency order. Updates the state file upon completion.terraform destroy: Safely tears down and deletes all resources managed by the configuration file (ideal for temporary testing environments).In professional engineering teams, storing the terraform.tfstate file on a developer's local laptop is a critical anti-pattern. If two developers run terraform apply simultaneously, the state file corrupts. Production Terraform requires a Remote Backend with State Locking:
# backend.tf - Production Remote State with S3 and DynamoDB Locking
terraform {
required_version = ">= 1.5.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
backend "s3" {
bucket = "veewom-terraform-state-prod"
key = "vpc/terraform.tfstate"
region = "us-east-1"
encrypt = true
dynamodb_table = "terraform-state-locks" # Prevents concurrent applies!
}
}
# main.tf - Declarative VPC & Subnet
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
tags = {
Name = "Veewom-Production-VPC"
Environment = "production"
ManagedBy = "Terraform"
}
}
resource "aws_subnet" "public_1" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
availability_zone = "us-east-1a"
map_public_ip_on_launch = true
tags = {
Name = "Veewom-Public-Subnet-1"
}
}
Broaden your enterprise cloud architecture and DevOps expertise across our curriculum:
Review state management, provider blocks, variables, outputs, and modular infrastructure architecture.
Evaluate Terraform versus native AWS CloudFormation and Azure Bicep for enterprise infrastructure.
Hands-on project: Provision a complete 3-tier VPC network with EC2 and RDS using Terraform.
Essential Terraform CLI reference: init, plan, apply, destroy, state list, and import commands.