Skip to content

🚀 Production-Ready DevOps Project: Automating Enterprise Infrastructure on AWS using Terraform, Docker, CI/CD, GitOps, and Monitoring (Prometheus + Grafana)

License

Notifications You must be signed in to change notification settings

elonerajeev/Enterprise-Grade-Infrastructure-Automation-with-Terraform-AWS

Repository files navigation

🚀 Enterprise-Grade Infrastructure Automation with Terraform + AWS

Project Banner Build and Push to Docker Hub Deploy to EC2 Terraform AWS Docker

Production-ready DevOps infrastructure automation showcasing modern cloud-native practices

🔥 Live Demo📖 Documentation🛠️ Getting Started💼 Portfolio


📋 Table of Contents


🎯 Project Overview

This project demonstrates enterprise-grade infrastructure automation by building a complete DevOps pipeline that provisions, deploys, and manages a containerized Node.js application on AWS using modern Infrastructure-as-Code (IaC) practices.

🎪 What Makes This Special?

  • 🔄 Fully Automated: Zero-touch deployment from code commit to production
  • 🏗️ Modular Infrastructure: Reusable Terraform modules for scalability
  • 🛡️ Security First: IAM roles, security groups, and secrets management
  • 📊 Production Ready: Application Load Balancer, health checks, and monitoring
  • 💰 Cost Optimized: Efficient resource utilization with AWS free tier

🏗️ Architecture

A beautiful landscape


🧰 Technology Stack

Category Technologies
☁️ Cloud Platform AWS (EC2, VPC, ALB, IAM, Route 53)
🏗️ Infrastructure as Code Terraform (Modular Architecture)
🐳 Containerization Docker, DockerHub Registry
🔄 CI/CD Pipeline GitHub Actions, Automated Workflows, Jenkins
🌐 Application Node.js, Express.js, RESTful APIs
🔒 Security IAM Roles, Security Groups, SSH Keys
📊 Monitoring Prometheus, Grafana, AWS CloudWatch
🔐 Secrets Management GitHub Secrets, AWS Secrets Manager

✨ Key Features

🎯 Infrastructure Automation

  • 🧩 Modular Terraform Design: Separate modules for VPC, EC2, ALB, and IAM, Others
  • 🌍 Multi-Environment Support: Dev, staging, and production configurations
  • 🔄 State Management: Remote state storage with S3 backend and DynamoDB locking

🚀 Deployment Pipeline

  • ⚡ Automated Builds: Trigger on every commit to main branch
  • 🐳 Container Registry: Automated push to DockerHub
  • 📡 Remote Deployment: SSH-based deployment to EC2 instances
  • 🔍 Health Monitoring: Application health checks and status monitoring

🛡️ Security & Best Practices

  • 🔐 Secrets Management: Secure handling of credentials and API keys
  • 🌐 Network Security: Custom VPC with public/private subnet architecture
  • 🚪 Access Control: IAM roles and security groups with least privilege
  • 🔒 SSH Hardening: Key-based authentication and secure connections

🚀 Quick Start

Prerequisites

# Required tools
aws --version          # AWS CLI
terraform --version    # Terraform >= 1.0
docker --version       # Docker
git --version         # Git

1️⃣ Clone & Setup

git clone https://github.com/elonerajeev/Enterprise-Grade-Infrastructure-Automation-with-Terraform-AWS.git
cd Enterprise-Grade-Infrastructure-Automation-with-Terraform-AWS
cd terraform/environments/dev

2️⃣ Configure AWS Credentials

aws configure
# Enter your AWS Access Key ID, Secret Access Key, and preferred region

3️⃣ Initialize Terraform

terraform init
terraform plan
terraform apply -auto-approve

4️⃣ Deploy Application

# Push to main branch triggers automatic deployment
# In Root Directory 
git add .
git commit -m "feat: deploy application"
git push origin main

📁 Project Structure

📦 Enterprise-Grade-Infrastructure-Automation/
├── 🏗️ terraform/
│   ├── 🌍 environments/
│   │   └── dev/
│   │       ├── main.tf              # Main configuration
│   │       ├── variables.tf         # Input variables
│   │       ├── outputs.tf           # Output values
│   │       └── terraform.tfvars     # Variable values
│   └── 📚 modules/
│       ├── vpc/                     # VPC module
│       ├── ec2/                     # EC2 module
│       ├── alb/                     # Load balancer module
│       └── iam/                     # IAM roles module
├── 🐳 app/
│   ├── src/                         # Application source
│   ├── Dockerfile.prod              # Production dockerfile
│   ├── package.json                 # Dependencies
│   └── healthcheck.js               # Health endpoint
├── 🔄 .github/
│   └── workflows/
│       └── build-and-push.yml       # CI pipeline
|       |__ deploy-to-ec2.yml        # CD Pipeline 
├── 📊 monitoring/                   # Monitoring configs
├── 🔒 secrets/                      # Secret templates
└── 📖 docs/                         # Documentation

🔄 CI/CD Pipeline

Workflow Overview In Short (Not Complete Script)

name: Build and Deploy to AWS EC2 

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: 📥 Checkout Code
      - name: 🐳 Build Docker Image
      - name: 📤 Push to DockerHub
      - name: 🚀 Deploy to EC2

Pipeline Stages

Stage Action Status
🔍 Code Analysis Lint and security scan ✅ Active
🏗️ Build Docker image creation ✅ Active
🧪 Test Unit and integration tests ✅ Active
📤 Publish Push to DockerHub registry ✅ Active
🚀 Deploy SSH deployment to EC2 ✅ Active
Verify Health check validation ✅ Active

💡 Implementation Highlights

🏗️ Modular Terraform Architecture

# Example: VPC Module Usage
module "vpc" {
  source = "../../modules/vpc"
  
  vpc_cidr             = var.vpc_cidr
  availability_zones   = var.availability_zones
  public_subnet_cidrs  = var.public_subnet_cidrs
  
  tags = local.common_tags
}

🐳 Optimized Docker Configuration

# Multi-stage build for production
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production && npm cache clean --force

FROM node:18-alpine AS runtime
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY . .
EXPOSE 3000
CMD ["node", "index.js"]

🔄 Automated Deployment Script

#!/bin/bash
# Deployed via GitHub Actions
docker pull elonerajeev/infra-app:latest
docker stop app-container || true
docker run -d --name app-container -p 80:3000 elonerajeev/infra-app:latest

🎯 Challenges & Solutions

🔧 Infrastructure Challenges
Challenge Solution Impact
VPC Module Dependencies Implemented proper output references ✅ Resolved
ALB Subnet Requirements Configured multi-AZ public subnets ⚡ Performance
State File Conflicts S3 backend with DynamoDB locking 🔒 Consistency
Security Group Rules Least privilege access principles 🛡️ Security
🚀 Deployment Challenges
Challenge Solution Impact
SSH Key Management GitHub Secrets integration 🔐 Security
Docker Registry Auth Automated token refresh 🔄 Reliability
Zero-Downtime Deployment Blue-green deployment strategy ⚡ Availability
Container Health Checks Custom health endpoint 📊 Monitoring

📈 Monitoring & Observability

Grafana Dashboard

alt text

alt text

Application Metrics

GET /metrics Response: Prometheus-formatted metrics

Planned Monitoring Stack

  • 📊 Prometheus: Metrics collection and alerting
  • 📈 Grafana: Visualization dashboards
  • 🔍 AWS CloudWatch: Infrastructure monitoring
  • 📱 Slack Integration: Alert notifications

👨‍💻 Author : elonerajeev

Rajeev Kumar
AWS DevOps Engineer & Cloud Architect

Portfolio LinkedIn GitHub Email

"Building scalable cloud infrastructure with modern DevOps practices"


📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License - Feel free to use this project for learning and development!

🌟 If you found this project helpful, please give it a star!

GitHub stars GitHub forks

Made with ❤️ and ☕ by Rajeev Kumar


About

🚀 Production-Ready DevOps Project: Automating Enterprise Infrastructure on AWS using Terraform, Docker, CI/CD, GitOps, and Monitoring (Prometheus + Grafana)

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •