Experiments

Terraform Docker Example

Reusable Terraform modules for managing Docker containers and AWS ECS Fargate, with progressive examples and local testing with LocalStack.

evergreen#terraform#docker#ecs#localstack#infrastructure-as-code

What it is

Reusable Terraform modules for managing Docker containers locally and on AWS ECS Fargate. Includes four progressive examples ranging from basic containers to ECS testing with LocalStack.

Available as source code.

Examples

  1. Basic Docker — container module, networking, and port mapping
  2. FastAPI + React — full-stack application with custom Dockerfiles
  3. Docker Compose — the same app for approach comparison
  4. ECS with LocalStack — AWS ECS testing at zero cost

Included modules

  • docker-container — local Docker container management with dynamic port mapping, environment variables, and network configuration
  • ecs-fargate — ECS clusters, task definitions, services, CloudWatch Logs, and Container Insights

Why it matters

Terraform and Docker Compose solve different problems. This project demonstrates when to use each with practical examples, and shows how to test AWS infrastructure locally with LocalStack before spending on the cloud.

References

Experiments