Lab write-up · sanitized, no company IP
ECS Fargate microservice
A containerized API running on AWS ECS Fargate with least-privilege IAM, provisioned end-to-end by Terraform and deployed through GitHub Actions.
AWSECS (Fargate)DockerTerraformGitHub Actions
// goal
Run a simple containerized API on ECS Fargate with least-privilege IAM, provisioned by Terraform — no servers to patch, no fleet to manage.
// architecture
- ALB (or public service) → ECS Service (Fargate) → Task (Docker image from ECR)
- Logs → CloudWatch; configuration via environment variables / SSM Parameter Store
// quick start
Local build → ECR → ECS, in three steps. Assumes a repo with an app/ directory (Dockerfile) and a terraform/ directory.
1. Build the app locally
cd app
docker build -t ecs-lab:demo .
2. Create the ECR repo (once) and push the image
aws ecr create-repository --repository-name ecs-lab
aws ecr get-login-password --region REGION | docker login --username AWS --password-stdin ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com
docker tag ecs-lab:demo ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/ecs-lab:demo
docker push ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/ecs-lab:demo
3. Wire up the ECS service with Terraform
cd ../terraform
terraform init
terraform apply
// what this demonstrates
- Containerizing an API in Docker
- Managing image lifecycle through ECR
- Infrastructure as code with Terraform (cluster, service, task definition)
- CI/CD with GitHub Actions: build the image, push it to ECR, and roll out a new task definition to the ECS service