Took everything I built by hand in the AWS Console and defined it as code. One command creates the entire infrastructure — ECR, ECS Fargate, IAM roles, security groups, CloudWatch logging. One command tears it all down. Version-controlled, reviewable, reproducible.
Architecture
.tf files
8 files, 7 resources
Terraform creates on AWS
ECS Cluster
ECS Service
Task Definition
ECR Repository
IAM Role + Policy
Security Group
CloudWatch Logs
State file tracks every resource. terraform destroy removes all 7 in the correct dependency order.
Why these technologies
Terraform over CloudFormation
CloudFormation is AWS-only. Terraform works with AWS, GCP, Azure, and 3,000+ providers. If I ever work with multi-cloud or non-AWS services, the same tool and language apply. The tradeoff is that CloudFormation has tighter AWS integration and catches some errors earlier.
IaC over console clicking
The console is fine for learning, but infrastructure built by hand is undocumented, unreproducible, and unauditable. With Terraform, the code IS the documentation. Changes go through pull requests. If a region goes down, terraform apply rebuilds everything elsewhere in minutes.
Separate repo over embedding in the app repo
Infrastructure and application code have different lifecycles. App code changes daily; infrastructure changes rarely. Separate repos mean separate CI/CD pipelines, separate permissions, and clearer ownership. The tradeoff is managing two repos instead of one.
Declarative IaC — define what you want, Terraform figures out how to build it
Plan before apply — always preview changes before they hit production
State management — Terraform tracks resources and detects drift