Terraform is my go-to for infrastructure provisioning. After managing hundreds of environments across AWS, Azure, and GCP, here is the practical guide.
Why This Matters
Infrastructure as Code is not optional anymore. Manual provisioning does not scale, is not auditable, and leads to configuration drift.
Prerequisites
- Terraform installed (Install Terraform on Ubuntu or macOS)
- Cloud provider account (AWS, Azure, or GCP)
- Text editor (VS Code recommended)
Step-by-Step Guide
Step 1: Initialize Your Project
# main.tf
terraform {
required_version = ">= 1.7"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
backend "s3" {
bucket = "my-terraform-state"
key = "prod/terraform.tfstate"
region = "eu-west-1"
}
}
provider "aws" {
region = var.aws_region
}Step 2: Write Resources
# vpc.tf
resource "aws_vpc" "main" {
cidr_block = var.vpc_cidr
enable_dns_hostnames = true
enable_dns_support = true
tags = {
Name = "${var.project}-vpc"
Environment = var.environment
ManagedBy = "terraform"
}
}Step 3: Plan and Apply
# Initialize
terraform init
# Preview changes
terraform plan -out=tfplan
# Apply
terraform apply tfplanCommon Mistakes
- Not using remote state โ local state files get lost or conflict
- Hardcoding values โ use variables and tfvars files
- No state locking โ concurrent applies corrupt state
- Giant monolithic configs โ use modules for reusability
Related Resources
- Terraform Cheat Sheet
- Terraform vs Ansible
- Terraform vs Pulumi
- Terraform Modules Best Practices
- Terraform State Management
About the Author
I am Luca Berton, AI and Cloud Advisor with 8 published books on automation, Kubernetes, and AI. Book a consultation to discuss your terraform aws strategy.

