Terraform
The leading infrastructure-as-code tool. Terraform lets you define cloud infrastructure across AWS, GCP, Azure, and 1000+ providers in declarative HCL and manage it with a consistent plan/apply workflow.
Why Terraform?
You want a consistent way to provision cloud resources across providers
You need to version-control your infrastructure like code
Your team needs repeatable, auditable infrastructure changes
Signal Breakdown
What drives the Trust Score
Download Trend
Last 12 months
Tradeoffs & Caveats
Know before you commitYou prefer your cloud provider's native IaC (CDK, Deployment Manager)
Your team is small and Terraform's state management overhead isn't worth it
The BSL license change is a concern — consider OpenTofu instead
Pricing
Free tier & paid plans
Open-source CLI free forever
$20/user/mo (Terraform Cloud Plus)
HCP Terraform free up to 500 resources
Often Used Together
Complementary tools that pair well with Terraform
Learning Resources
Docs, videos, tutorials, and courses
Get Started
Repository and installation options
View on GitHub
github.com/hashicorp/terraform
brew install terraformcurl -fsSL https://releases.hashicorp.com/terraform | shQuick Start
Copy and adapt to get going fast
terraform {
required_providers {
aws = { source = "hashicorp/aws", version = "~> 5.0" }
}
backend "s3" {
bucket = "my-tf-state"
key = "prod/terraform.tfstate"
region = "us-east-1"
}
}
resource "aws_s3_bucket" "app_assets" {
bucket = "my-app-assets-${var.env}"
}
resource "aws_ecs_service" "app" {
name = "my-app"
cluster = aws_ecs_cluster.main.id
desired_count = 2
}
# terraform init && terraform plan && terraform applyCode Examples
Common usage patterns
Variables and outputs
Parameterize infrastructure with variables
# variables.tf
variable "env" {
description = "Deployment environment"
type = string
default = "staging"
}
variable "instance_count" {
type = number
default = 2
}
# outputs.tf
output "load_balancer_url" {
value = aws_lb.main.dns_name
}AWS RDS + VPC module
Create a Postgres RDS instance inside a VPC
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 5.0"
name = "my-vpc"
cidr = "10.0.0.0/16"
azs = ["us-east-1a", "us-east-1b"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
}
resource "aws_db_instance" "postgres" {
engine = "postgres"
engine_version = "16"
instance_class = "db.t3.micro"
allocated_storage = 20
db_name = "myapp"
username = var.db_user
password = var.db_password
db_subnet_group_name = aws_db_subnet_group.main.name
skip_final_snapshot = true
}Workspace-based environments
Use Terraform workspaces for dev/staging/prod
# Create and switch workspace
terraform workspace new staging
terraform workspace select staging
# Reference workspace in config
resource "aws_instance" "app" {
instance_type = terraform.workspace == "prod" ? "t3.medium" : "t3.micro"
tags = {
Environment = terraform.workspace
}
}Community Notes
Real experiences from developers who've used this tool