Skip to content

mohsin1217/terraform-devops-stack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Terraform Docker DevOps Stack – Nginx + Prometheus + Grafana

A complete local DevOps Monitoring Stack built using Terraform, the Docker provider, and custom container resources. This project provisions:

  • πŸ“ˆ Prometheus for metrics collection
  • πŸ“Š Grafana for visualization
  • πŸ“‘ Node Exporter for system metrics
  • 🌐 A custom Nginx web server for simulating a static web app

βœ… Entire stack is provisioned using Infrastructure as Code (IaC) β€” no manual Docker CLI or Compose!


πŸ› οΈ Tools & Technologies

Tool Purpose
Terraform Infrastructure as Code
Docker Containerization
Nginx Static Web Server
Prometheus Metrics collection
Grafana Dashboards & Visualization
Node Exporter Host system metrics exporter

🧾 Project Structure

terraform-devops-stack/
β”œβ”€β”€ main.tf
β”œβ”€β”€ variables.tf
β”œβ”€β”€ outputs.tf
β”œβ”€β”€ terraform.tfvars
β”œβ”€β”€ prometheus/
β”‚   └── prometheus.yml
β”œβ”€β”€ nginx/
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── index.html
β”œβ”€β”€ grafana/
β”‚   └── provisioning/
β”‚       └── dashboards/   # Optional JSON dashboards
└── README.md
🚦 How It Works
Terraform provisions Docker images & containers with all configurations.

prometheus.yml is mounted inside the Prometheus container.

Grafana uses provisioning to auto-detect Prometheus as a data source.

Nginx serves a custom HTML file on port 8080.

Node Exporter runs on port 9100, monitored by Prometheus.

▢️ Getting Started
πŸ“¦ Prerequisites
Docker installed and running

Terraform v1.6+ installed

VS Code (recommended)

πŸš€ Run the Stack
bash
ΰ€•ΰ₯‰ΰ€ͺΰ₯€ ΰ€•ΰ€°ΰ₯‡ΰ€‚
ΰ€¬ΰ€¦ΰ€²ΰ₯‡ΰ€‚
# Clone the repository
git clone https://github.com/your-username/terraform-devops-stack.git
cd terraform-devops-stack

# Initialize and apply Terraform
terraform init
terraform apply
🌐 Access the Services
Service	URL
πŸ” Nginx	http://localhost:8080
πŸ“Š Grafana	http://localhost:3000
πŸ“ˆ Prometheus	http://localhost:9090
πŸ›° Node Exporter	http://localhost:9100/metrics

Grafana Login

Username: admin

Password: admin (default)

πŸ“Έ Screenshots
πŸ–₯️ Custom Nginx Page
![image](https://github.com/user-attachments/assets/892d59ef-cfd7-4e58-9187-66afaf1f91cf)


πŸ“ˆ Prometheus UI
![image](https://github.com/user-attachments/assets/dc218978-a908-42d2-a9cd-4571e5226afb)


πŸ“Š Grafana Dashboard
![image](https://github.com/user-attachments/assets/d95ddd5d-117b-413c-93c0-191488842d1b)


πŸ“š Learning Outcomes
Built a monitoring stack from scratch using only Terraform and Docker.

Practiced defining volumes, networks, and multi-container setup with IaC.

Understood how observability tools connect in a real-world scenario.

No use of Docker Compose or cloudβ€”everything runs locally and is reproducible.

βœ… Next Goals (Ideas to Extend)
Add Alertmanager for Prometheus.

Integrate a backend app (Flask/Node.js) instead of static Nginx.

Push this stack to a VM or cloud environment.

Auto-provision Grafana dashboards using JSON.

πŸ™‹β€β™‚οΈ Author
Sayed Mohsin Ali
πŸ‘¨β€πŸ’» DevOps Engineer | 3.5 YOE | Azure | Terraform | Kubernetes
πŸ“ LinkedIn
🌐 GitHub

πŸ’‘ If this helped you, feel free to ⭐ the repo and connect with me!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages