Terraform
In one line
Terraform is an Infrastructure as Code (IaC) tool that lets you define and provision cloud infrastructure using declarative configuration files.
In simple words
Terraform is a tool by HashiCorp that lets you define your infrastructure — servers, databases, networks, load balancers — as code. Instead of clicking through a cloud console to create resources, you write configuration files and Terraform creates everything for you.
Terraform uses a declarative approach: you describe what you want (e.g., "I want 3 servers and a load balancer"), and Terraform figures out how to create it. It tracks the state of your infrastructure in a state file, so when you change your configuration, Terraform knows what already exists and only creates/updates/deletes what changed.
Terraform works with all major cloud providers (AWS, Azure, GCP) and many other services through providers. This means you can use the same tool and language to manage infrastructure across different clouds.
Example
resource "aws_instance" "web" {
ami = "ami-12345678"
instance_type = "t2.micro"
count = 3
tags = {
Name = "WebServer"
}
}This Terraform code creates 3 AWS EC2 instances using the specified AMI and instance type.
How it works
- You write infrastructure definitions in HCL (HashiCorp Configuration Language).
terraform planshows what will be created, changed, or destroyed.terraform applyexecutes the changes against your cloud provider.- Terraform stores the state in a state file so it can manage updates.
Common confusions
Confused with: Ansible
The difference: Terraform provisions infrastructure (creates resources); Ansible configures existing servers (installs software, manages files).
Related terms
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.