Jonatan Matajonmatum.com
conceptsnotesexperimentsessays
© 2026 Jonatan Mata. All rights reserved.v2.1.1
Experiments

Terraform Docker Example

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

seed#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

  • GitHub Repository — jonmatum, 2025. Source code, modules, and documentation.
  • Terraform Docker Provider — kreuzwerker, 2024. Provider documentation.
  • LocalStack — LocalStack, 2024. Local AWS service emulator.

Related content

  • Terraform

    HashiCorp's Infrastructure as Code tool that enables defining, provisioning, and managing multi-cloud infrastructure through declarative HCL files.

  • Infrastructure as Code

    Practice of defining and managing infrastructure through versioned configuration files instead of manual processes. Foundation of modern operations automation.

Experiments