⏱ Duration: 5 Hours
📚 Learning Objectives
- Review and finalize project requirements
- Design system architecture for the capstone project
- Set up and configure the project repository
- Create project documentation structure
- Plan sprint tasks and milestones
🎯 Capstone Project Overview
Project Requirements
Capstone Project: End-to-End DevOps Pipeline
┌─────────────────────────────────────────────────────────┐
│ REQUIRED COMPONENTS │
├─────────────────────────────────────────────────────────┤
│ 1. Python Application │
│ • REST API with Flask/FastAPI │
│ • Health check endpoint │
│ • Environment variable configuration │
│ │
│ 2. Docker │
│ • Multi-stage Dockerfile │
│ • Docker Compose for local development │
│ • Image pushed to Docker Hub/ECR │
│ │
│ 3. AWS EC2 Infrastructure │
│ • EC2 instance running application │
│ • Security groups configured │
│ • VPC with public subnet │
│ │
│ 4. Terraform │
│ • Infrastructure as Code for all AWS resources │
│ • Remote state management │
│ • Modular configuration │
│ │
│ 5. CI/CD Pipeline │
│ • GitHub Actions workflow │
│ • Automated testing │
│ • Automated deployment to EC2 │
│ │
│ 6. Documentation │
│ • README with setup instructions │
│ • Architecture diagrams │
│ • Runbook for operations │
└─────────────────────────────────────────────────────────┘📖 Core Concepts (2 Hours)
System Architecture Design
Architecture Overview:
┌─────────────────────────────────────────────────────────┐
│ GitHub Repository │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │
│ │ Python App │ │ Dockerfile │ │ Terraform Files │ │
│ │ Source Code │ │ │ │ │ │
│ └──────┬──────┘ └──────┬──────┘ └────────┬────────┘ │
└─────────┼────────────────┼──────────────────┼──────────┘
│ │ │
▼ ▼ ▼
┌─────────────────────────────────────────────────────────┐
│ GitHub Actions CI/CD Pipeline │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌───────────┐ │
│ │ Test │→ │ Build │→ │ Push │→ │ Deploy │ │
│ │ │ │ Docker │ │ to Hub │ │ to EC2 │ │
│ └─────────┘ └─────────┘ └─────────┘ └───────────┘ │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ AWS Cloud │
│ ┌─────────────────────────────────────────────────┐ │
│ │ VPC │ │
│ │ ┌─────────────────────────────────────────┐ │ │
│ │ │ Public Subnet │ │ │
│ │ │ ┌─────────────────────────────────┐ │ │ │
│ │ │ │ EC2 Instance │ │ │ │
│ │ │ │ ┌─────────────────────────┐ │ │ │ │
│ │ │ │ │ Docker Container │ │ │ │ │
│ │ │ │ │ (Python App) │ │ │ │ │
│ │ │ │ └─────────────────────────┘ │ │ │ │
│ │ │ └─────────────────────────────────┘ │ │ │
│ │ └─────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘Project Directory Structure
capstone-project/
├── app/
│ ├── __init__.py
│ ├── main.py # Flask/FastAPI application
│ ├── routes.py # API endpoints
│ └── requirements.txt # Python dependencies
├── docker/
│ ├── Dockerfile # Multi-stage build
│ └── docker-compose.yml # Local development
├── terraform/
│ ├── main.tf # Main configuration
│ ├── variables.tf # Input variables
│ ├── outputs.tf # Output values
│ ├── vpc.tf # VPC configuration
│ ├── ec2.tf # EC2 instance
│ └── security_groups.tf # Security groups
├── .github/
│ └── workflows/
│ └── cicd.yml # GitHub Actions pipeline
├── docs/
│ ├── architecture.md # Architecture documentation
│ └── runbook.md # Operations runbook
├── tests/
│ └── test_app.py # Unit tests
├── README.md # Project documentation
└── .gitignore # Git ignore fileGit Repository Setup
# Create project directory
mkdir capstone-project && cd capstone-project
# Initialize Git repository
git init
# Create .gitignore
cat > .gitignore << 'EOF'
# Python
__pycache__/
*.py[cod]
*$py.class
.Python
venv/
.env
# Terraform
.terraform/
*.tfstate
*.tfstate.backup
*.tfplan
.terraform.lock.hcl
# IDE
.vscode/
.idea/
*.swp
# OS
.DS_Store
Thumbs.db
# Docker
*.log
EOF
# Create directory structure
mkdir -p app docker terraform/.github/workflows docs tests
# Initialize empty files
touch app/__init__.py
touch app/main.py
touch app/routes.py
touch app/requirements.txt
touch docker/Dockerfile
touch docker/docker-compose.yml
touch terraform/main.tf
touch terraform/variables.tf
touch terraform/outputs.tf
touch .github/workflows/cicd.yml
touch docs/architecture.md
touch docs/runbook.md
touch tests/test_app.py
# Create initial README
cat > README.md << 'EOF'
# DevOps Capstone Project
End-to-end DevOps pipeline demonstrating:
- Python REST API application
- Docker containerization
- AWS EC2 infrastructure with Terraform
- CI/CD pipeline with GitHub Actions
## Quick Start
```bash
# Local development
docker-compose up -d
# Deploy infrastructure
cd terraform && terraform init && terraform apply
# Run tests
pytest tests/
```
## Architecture
See [docs/architecture.md](docs/architecture.md)
## Contributing
1. Fork the repository
2. Create feature branch
3. Submit pull request
EOF
# Initial commit
git add .
git commit -m "Initial project structure"🔬 Hands-on Lab (2.5 Hours)
Lab 1: Create GitHub Repository
# Create repository on GitHub
# Option 1: Using GitHub CLI
gh repo create capstone-project --public --description "DevOps Capstone Project"
# Option 2: Create on github.com, then:
git remote add origin https://github.com/YOUR_USERNAME/capstone-project.git
git branch -M main
git push -u origin main
# Enable branch protection (recommended)
# Settings → Branches → Add rule
# - Require pull request reviews
# - Require status checks to passLab 2: Create Architecture Diagram
# Create architecture documentation
cat > docs/architecture.md << 'EOF'
# System Architecture
## Overview
This project implements a complete DevOps pipeline for a Python web application.
## Components
### Application Layer
- **Technology**: Python 3.11 with Flask/FastAPI
- **Features**: REST API with health checks
- **Port**: 8000
### Container Layer
- **Runtime**: Docker
- **Base Image**: python:3.11-slim
- **Registry**: Docker Hub
### Infrastructure Layer
- **Cloud**: AWS
- **Compute**: EC2 t2.micro
- **Network**: VPC with public subnet
- **Security**: Security groups (ports 22, 80, 8000)
### CI/CD Layer
- **Platform**: GitHub Actions
- **Triggers**: Push to main, Pull requests
- **Stages**: Test → Build → Push → Deploy
## Data Flow
1. Developer pushes code to GitHub
2. GitHub Actions triggers pipeline
3. Tests run automatically
4. Docker image built and pushed
5. Terraform applies infrastructure changes
6. Application deployed to EC2
## Security Considerations
- Secrets stored in GitHub Secrets
- SSH keys managed securely
- Security groups limit access
- No hardcoded credentials
EOFLab 3: Sprint Planning
# Create project milestones and tasks
Week 8 Sprint Plan:
┌─────────────────────────────────────────────────────────┐
│ Day 1: Planning │
│ □ Review all requirements │
│ □ Design architecture │
│ □ Set up repository │
│ □ Create documentation structure │
├─────────────────────────────────────────────────────────┤
│ Day 2: Application │
│ □ Create Python Flask/FastAPI app │
│ □ Implement API endpoints │
│ □ Write unit tests │
│ □ Create Dockerfile │
├─────────────────────────────────────────────────────────┤
│ Day 3: Infrastructure │
│ □ Write Terraform configuration │
│ □ Create VPC and networking │
│ □ Set up EC2 instance │
│ □ Create GitHub Actions workflow │
├─────────────────────────────────────────────────────────┤
│ Day 4: Integration │
│ □ Connect CI/CD to infrastructure │
│ □ Test full deployment pipeline │
│ □ Fix issues and optimize │
│ □ Verify end-to-end functionality │
├─────────────────────────────────────────────────────────┤
│ Day 5: Presentation │
│ □ Complete documentation │
│ □ Prepare demo │
│ □ Practice presentation │
│ □ Showcase project │
└─────────────────────────────────────────────────────────┘
# Create GitHub Issues for tracking (optional)
gh issue create --title "Day 1: Project Setup" --body "Set up repository and documentation"
gh issue create --title "Day 2: Application Development" --body "Create Python app and Docker"
gh issue create --title "Day 3: Infrastructure Setup" --body "Terraform and CI/CD pipeline"
gh issue create --title "Day 4: Integration Testing" --body "Connect all pieces, test E2E"
gh issue create --title "Day 5: Documentation & Demo" --body "Complete docs and present"✅ Day 1 Checklist
- Reviewed all capstone project requirements
- Designed system architecture diagram
- Created and initialized Git repository
- Set up project directory structure
- Created initial documentation
- Planned sprint tasks for the week