This project demonstrates how to design and provision a modular Infrastructure as Code (IaC) solution using Terraform and the Docker provider. The infrastructure deploys a complete three-tier application composed of a PostgreSQL database, a Django REST API backend, and a React frontend while following Terraform best practices for modularity and reusability.
Terraform
│
┌───────────────┼────────────────┐
│ │ │
Docker Network Docker Volume Docker Images
│ │
├───────────────┼──────────────────────────┐
│ │ │
PostgreSQL Django Backend React Frontend
This project was created to practice and demonstrate Terraform best practices, including:
- Infrastructure as Code (IaC)
- Modular architecture
- Docker resource management
- Reusable Terraform modules
- Infrastructure organization
- Terraform
- Docker Provider
- Docker
- PostgreSQL
- Django REST Framework
- React
- GitHub Container Registry / Harbor
terraform/
├── main.tf # Root module that orchestrates child modules
├── variables.tf # Global input variables
├── outputs.tf # Root outputs
├── providers.tf # Provider configuration
├── versions.tf # Terraform and provider version constraints
├── README.md
└── modules/
├── db/
├── backend/
└── client/
----------------------------------------------------
| Module | Responsibility |
| ------- | -------------------------------------- |
| db | Creates PostgreSQL image and container |
| backend | Deploys Django REST API container |
| client | Deploys React frontend container |
Root Module
│
┌────────────┼────────────┐
│ │ │
db module backend module client module
│ │ │
PostgreSQL Django API React App
- Docker Engine
- Terraform >= 1.0
- Docker Provider (kreuzwerker/docker)
- Access to the container registry
git clone https://github.com/yclicourt/terraform-modules-task-app-fullstack.git
cd terraform-taskapp
cp terraform.tfvars.example terraform.tfvars
terraform init
terraform applyBefore running Terraform create:
cp terraform.tfvars.example terraform.tfvars
terraform init
terraform plan
terraform apply
terraform destroy- Modular Terraform architecture
- Docker infrastructure provisioning
- Private container registry integration
- Persistent PostgreSQL storage
- Network isolation
- Environment based configuration
- Root and child modules
- Input variables
- Output values
- Provider configuration
- Docker resources
- Resource dependencies
- Persistent volumes
- Custom Docker networks
- Modular Infrastructure as Code
The infrastructure is divided into reusable modules to separate responsibilities:
- Database module
- Backend module
- Frontend module
This structure improves maintainability, reusability and scalability while following Terraform best practices.
✔ Completed
Current implementation includes:
- Terraform modular architecture
- Docker provider
- PostgreSQL container
- Django backend
- React frontend
- Custom Docker network
- Persistent Docker volume
MIT License
- GitHub Actions CI/CD
- Remote Backend (S3, GCS or Azure Storage)
- Secret management with Vault
- Kubernetes deployment using Terraform
- Helm integration



