πŸ“ Tutorials
Β· 2 min read
Last updated on

What is Terraform? A Simple Explanation for Developers


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

  1. Write .tf files describing your infrastructure
  2. terraform plan β€” shows what will change (preview)
  3. terraform apply β€” creates/updates the resources
  4. terraform 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

ToolLanguageCloud supportBest for
TerraformHCLAll cloudsMulti-cloud, most popular
CloudFormationJSON/YAMLAWS onlyAWS-only shops
PulumiPython/TS/GoAll cloudsDevs who prefer real languages
CDKTypeScriptAWS (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.

For a detailed comparison of IaC tools, see Terraform vs Pulumi. If you’re choosing a cloud provider, check AWS vs GCP vs Azure.

FAQ

Is Terraform free to use?

Terraform CLI is free and open source. HashiCorp also offers Terraform Cloud (free tier for small teams) and Terraform Enterprise (paid) which add collaboration features, remote state management, and policy enforcement.

What happens if I lose my Terraform state file?

Losing the state file means Terraform no longer knows what resources it manages. You’d need to import existing resources back into state manually, which is tedious. Always store state remotely (S3, Terraform Cloud) with versioning and backups enabled.

Can I use Terraform for a single cloud provider, or is it only for multi-cloud?

Terraform works great with a single cloud provider. While multi-cloud is a common use case, most teams use Terraform with just AWS or just GCP. The benefit is infrastructure as code regardless of how many clouds you use.

Related: What is Serverless? A Simple Explanation for Developers