Terraform is an infrastructure-as-code tool. Instead of clicking around in the AWS/GCP/Azure console to create servers, databases, and networks, you write code that describes what you want, and Terraform creates it for you.
resource "aws_instance" "web" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t3.micro"
tags = { Name = "my-web-server" }
}
Run terraform apply, and Terraform creates an EC2 instance. Run it again β nothing happens (itβs already there). Change the instance type and run again β Terraform updates it. Delete the code and run again β Terraform destroys it.
Why infrastructure as code
Without IaC: you click through the AWS console, create 15 resources, forget what you configured, canβt reproduce it, and your coworker has no idea whatβs running.
With Terraform: your infrastructure is in Git. Itβs versioned, reviewable, reproducible, and documented. You can spin up an identical environment in minutes.
How it works
- Write
.tffiles describing your infrastructure terraform planβ shows what will change (preview)terraform applyβ creates/updates the resourcesterraform destroyβ tears everything down
Terraform tracks what it created in a state file, so it knows the difference between what exists and what you want.
Providers
Terraform works with 3,000+ providers β AWS, GCP, Azure, Cloudflare, GitHub, Datadog, Vercel, and more. Each provider gives you resources to manage:
# AWS
resource "aws_s3_bucket" "files" { bucket = "my-files" }
# Cloudflare
resource "cloudflare_record" "www" {
zone_id = "abc123"
name = "www"
value = "1.2.3.4"
type = "A"
}
Terraform vs. alternatives
| Tool | Language | Cloud support | Best for |
|---|---|---|---|
| Terraform | HCL | All clouds | Multi-cloud, most popular |
| CloudFormation | JSON/YAML | AWS only | AWS-only shops |
| Pulumi | Python/TS/Go | All clouds | Devs who prefer real languages |
| CDK | TypeScript | AWS (mainly) | AWS + TypeScript teams |
When to use Terraform
Good fit: managing cloud infrastructure, multi-cloud setups, teams that want reproducible environments, anything beyond a single server.
Overkill for: a single VPS, hobby projects on Vercel/Netlify (they handle infra for you), or if you only use one cloud and prefer its native tools.
For the full command reference, see the Terraform cheat sheet.