A simple, production-ready Django Todo App deployed with a full CI/CD pipeline using Jenkins, Terraform, Ansible, Docker Compose, and AWS EC2 — all in one click.
Add tasks, mark them complete, or delete them — but more importantly, deploy this app without touching a terminal manually. This project automates provisioning, deployment, and teardown of the entire stack.
- ✅ Django-based Todo Web Application
- 🐳 Containerized with Docker Compose
- 🧩 Three-tier architecture: Django + MySQL + Nginx
- ⚙️ CI/CD using Jenkins Pipeline
- 🌩️ Infrastructure as Code with Terraform (AWS EC2)
- 🔐 Remote provisioning using Ansible
- 🔄 Automatic infra teardown with confirmation prompt
- 🧪 Fully automated from repo clone to live app
django-todo-cicd/
├── ansible/ # Ansible playbooks and inventory
├── terraform/ # Terraform files (main.tf, variables.tf, etc.)
├── Jenkinsfile # CI/CD pipeline steps
├── docker-compose.yml # Docker Compose config
├── .env # Environment variables for containers
├── manage.py # Django entry point
└── ... # Django project files| Layer | Tool |
|---|---|
| Web App | Django (Python) |
| Web Server | Nginx |
| Database | MySQL |
| CI/CD | Jenkins + Jenkinsfile |
| Provision | Terraform (AWS EC2) |
| Config Mgmt | Ansible |
| Container | Docker Compose |
| Infra | AWS (EC2 only) |
-
Trigger Jenkins by pointing it to the repo.
-
Jenkinsfile performs the following:
-
Clones the repo
-
Executes
terraform applyto:- Provision an EC2 instance
- Create key pair and security group
- Save outputs (IP + key)
-
Waits for the instance (port 22) to become ready
-
Generates Ansible inventory from
terraform output -
Runs Ansible Playbook to:
- SSH into EC2
- Install Docker & Docker Compose
- Clone the repo
- Run the app using
docker-compose up
-
-
App is live at the EC2’s public IP on port 80
-
Pipeline prompts to confirm infra destruction
-
If confirmed, it runs
terraform destroy
These tools must be pre-installed on the Jenkins host machine.
- Jenkins
- Terraform
- Ansible
- Docker & Docker Compose
- AWS IAM credentials stored in Jenkins credentials store
Make sure the following plugins are installed on your Jenkins instance:
- Pipeline
- Pipeline: AWS Steps
- Pipeline: Input Step
- Git Plugin
- Docker Pipeline
- AWS Credentials
- Credentials
- Credentials Binding
- SSH Credentials
- Timestamper
- Workspace Cleanup
✅ Tip: Go to
Manage Jenkins → Plugin Manager → Installedto verify.
git clone https://github.com/amitkumar0128/django-todo-cicd.git
cd django-todo-cicd-
Set up a Jenkins pipeline project
-
In the pipeline config, point to the
Jenkinsfilein this repo -
Add your AWS credentials in Jenkins:
- Go to Manage Jenkins > Credentials
- Add AWS Access Key ID and Secret (ID:
AWS_CREDENTIALS_IDif used in pipeline)
- Run the pipeline
- Watch automation magic happen 😎
graph TD;
A[Start Jenkins Pipeline] --> B[Clone Repo]
B --> C[Terraform Init & Apply]
C --> D[Provision EC2, Key, SG]
D --> E[Save IP & Key to tf_outputs.json]
E --> F[Generate Ansible Inventory]
F --> G[Wait for SSH port 22 open]
G --> H[Run Ansible Playbook]
H --> I[Install Docker & Clone Repo on EC2]
I --> J[Run docker-compose up]
J --> K[App Live on EC2 IP:80]
K --> L[Manual Confirm for Teardown]
L --> M[terraform destroy]
Once deployed, visit:
http://<EC2_PUBLIC_IP>
- Add a new task
- Mark as completed
- Delete tasks
- Add CI badges
- Enable HTTPS with Let's Encrypt
- Add monitoring via Prometheus & Grafana
- Auto-scale infra using ASG (future)
Contributions are welcome! Feel free to submit pull requests or open issues.
Amit Kumar 🔗 GitHub