HashiCorp's Infrastructure as Code tool that enables defining, provisioning, and managing multi-cloud infrastructure through declarative HCL files.
Terraform is the most widely adopted IaC tool on the market. It uses a declarative language (HCL) to define infrastructure and a state model to track which resources exist and how to update them.
Write (.tf files) → Plan (preview changes) → Apply (execute changes)
terraform init # Download providers and modules
terraform validate # Verify syntax
terraform plan # See what will change
terraform apply # Apply changes
terraform destroy # Delete all infrastructurePlugins that connect Terraform to service APIs:
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = "us-east-1"
}Over 4,000 providers: AWS, Azure, GCP, Kubernetes, GitHub, Datadog, Cloudflare, etc.
Basic unit — an infrastructure resource:
resource "aws_s3_bucket" "data" {
bucket = "my-app-data-${var.environment}"
tags = {
Environment = var.environment
ManagedBy = "terraform"
}
}
resource "aws_s3_bucket_versioning" "data" {
bucket = aws_s3_bucket.data.id
versioning_configuration {
status = "Enabled"
}
}# variables.tf
variable "environment" {
description = "Deployment environment"
type = string
validation {
condition = contains(["dev", "staging", "prod"], var.environment)
error_message = "Must be dev, staging, or prod."
}
}
variable "instance_count" {
description = "Number of instances"
type = number
default = 2
}# terraform.tfvars
environment = "prod"
instance_count = 3output "bucket_arn" {
description = "ARN of the S3 bucket"
value = aws_s3_bucket.data.arn
}
output "api_url" {
description = "API Gateway URL"
value = aws_apigatewayv2_api.main.api_endpoint
sensitive = false
}Read information from existing resources (not managed by Terraform):
data "aws_ami" "amazon_linux" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["al2023-ami-*-x86_64"]
}
}
resource "aws_instance" "web" {
ami = data.aws_ami.amazon_linux.id
instance_type = "t3.micro"
}The state file is the source of truth about which resources exist:
# Remote backend (mandatory for teams)
terraform {
backend "s3" {
bucket = "company-terraform-state"
key = "services/api/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-locks" # Locking
encrypt = true # Encryption at rest
}
}terraform state list # List resources
terraform state show aws_instance.web # Resource detail
terraform state mv aws_instance.old aws_instance.new # Rename
terraform state rm aws_instance.legacy # Stop managing
terraform import aws_instance.web i-1234567890 # Import existingReusable infrastructure packages:
# Custom module
module "api" {
source = "./modules/lambda-api"
function_name = "my-api"
runtime = "nodejs20.x"
memory_size = 256
environment = var.environment
}
# Registry module
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "5.5.0"
name = "production"
cidr = "10.0.0.0/16"
}modules/lambda-api/
├── main.tf # Resources
├── variables.tf # Inputs
├── outputs.tf # Outputs
├── versions.tf # Provider requirements
└── README.md # Documentation
Multiple environments with the same code:
terraform workspace new staging
terraform workspace new production
terraform workspace select staging
terraform apply -var-file="staging.tfvars"# Create multiple resources
resource "aws_iam_user" "team" {
for_each = toset(["alice", "bob", "carol"])
name = each.key
}
# Conditional
resource "aws_cloudwatch_log_group" "api" {
count = var.enable_logging ? 1 : 0
name = "/api/${var.environment}"
}moved {
from = aws_instance.server
to = aws_instance.web
}| Aspect | Terraform | Pulumi | AWS CDK | CloudFormation |
|---|---|---|---|---|
| Language | HCL | TS, Python, Go | TS, Python | YAML/JSON |
| Multi-cloud | Yes | Yes | No (AWS) | No (AWS) |
| State | Self-managed/Cloud | Managed/self | AWS-managed | AWS-managed |
| Ecosystem | 4,000+ providers | 100+ providers | AWS only | AWS only |
| License | BSL 1.1 | Apache 2.0 | Apache 2.0 | Proprietary |
| OSS Fork | OpenTofu | — | — | — |
# Never hardcode secrets
variable "db_password" {
type = string
sensitive = true # Won't appear in logs or plan
}
# Use data sources for secrets
data "aws_secretsmanager_secret_version" "db" {
secret_id = "prod/db/password"
}main.tf. Split by domain.terraform fmt — consistent formatting makes code review easier.Terraform has become the de facto standard for infrastructure as code. Mastering it is not optional for teams operating in the cloud — it is the difference between reproducible, auditable infrastructure and manual configuration that no one can reconstruct when it fails.
Practice of defining and managing infrastructure through versioned configuration files instead of manual processes. Foundation of modern operations automation.
Set of technical and cultural practices that implement DevOps principles — from Infrastructure as Code to blameless post-mortems. The "how" behind the philosophy.
Continuous Integration and Continuous Delivery/Deployment — practices that automate code integration, testing, and delivery to production. Foundation of modern software engineering.
Reusable Terraform modules for managing Docker containers and AWS ECS Fargate, with progressive examples and local testing with LocalStack.
Collection of 13 Terraform modules published on the Terraform Registry for deploying serverless architectures on AWS, with 12 examples covering basic ECS to full-stack CRUD with DynamoDB and AgentCore with MCP.
Serverless GitHub App that auto-approves pull requests after CI passes, with optional AI code review via Amazon Bedrock. Five repositories: TypeScript/Probot app, AWS Terraform module (Lambda + API Gateway + Secrets Manager + SQS DLQ), GitHub Terraform module (webhooks), deployment infra, and test repo.
Three-agent system that automates the bilingual MDX content lifecycle: deterministic QA auditing, surgical fixes, and full upgrades — all orchestrated with Strands Agents, Claude Sonnet 4 on Amazon Bedrock, and GitHub Actions with a diamond workflow pattern.
Open source fork of Terraform maintained by the Linux Foundation. Compatible with HCL and Terraform providers, created in response to HashiCorp's license change to BSL 1.1.
AWS native service for defining and provisioning infrastructure as code using YAML or JSON templates, with state management and automatic rollback.