Skip to content

vinsin21/cloud-quiz-craft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ CloudQuiz - Production-Ready Frontend Deployment with AWS & Terraform

A complete DevOps demonstration showcasing automated deployment of a React.js application using AWS services, Terraform Infrastructure as Code, and GitHub Actions CI/CD pipeline.

AWS Architecture Terraform GitHub Actions React

πŸ“‹ Table of Contents

🎯 Project Overview

This project demonstrates production-grade frontend deployment using modern DevOps practices. It's designed to showcase skills in:

  • Infrastructure as Code with Terraform
  • Automated CI/CD with GitHub Actions
  • AWS Cloud Services integration
  • Security best practices
  • Cost-effective architecture

🌟 Key Features

βœ… Fully Automated Deployment - Push to main branch triggers complete deployment
βœ… Secure Architecture - Private S3 bucket with CloudFront OAI
βœ… Global Content Delivery - CloudFront CDN for worldwide performance
βœ… Infrastructure as Code - Reproducible infrastructure with Terraform
βœ… Zero-Downtime Deployments - Automated cache invalidation
βœ… Cost Optimized - Serverless architecture with minimal costs

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Developer     │───▢│  GitHub Actions  │───▢│   AWS Cloud     β”‚
β”‚   (git push)    β”‚    β”‚     CI/CD        β”‚    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚   React Build    β”‚
                       β”‚   (npm run build)β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚   S3 Bucket      β”‚
                       β”‚   (Static Files) β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚   CloudFront     β”‚
                       β”‚   (Global CDN)   β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚   End Users      β”‚
                       β”‚   (Worldwide)    β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

AWS Services Used

Service Purpose Configuration
S3 Static file storage Private bucket with encryption
CloudFront Global CDN HTTPS redirect, caching optimized
IAM Access management OIDC provider, roles, policies
Route 53 DNS (optional) Custom domain support

πŸ› οΈ Technologies Used

Frontend

  • React 18 - Modern UI library
  • Vite - Fast build tool
  • TypeScript - Type safety
  • Tailwind CSS - Utility-first styling

Infrastructure

  • Terraform - Infrastructure as Code
  • AWS CLI - Command-line interface
  • GitHub Actions - CI/CD automation

DevOps

  • Git - Version control
  • GitHub - Repository hosting
  • OIDC - Secure authentication

⚑ Quick Start

Prerequisites

  • AWS Account with appropriate permissions
  • GitHub Account
  • Node.js 18+ installed
  • Git installed
  • Terraform installed (1.0+)
  • AWS CLI configured

πŸš€ Deploy Infrastructure

  1. Clone the repository

    git clone https://github.com/vinsin21/cloud-quiz-craft.git
    cd cloud-quiz-craft
  2. Configure AWS credentials

    aws configure
    # Enter your AWS Access Key ID, Secret Access Key, and region
  3. Update Terraform variables

    cd terraform

    Edit terraform.tfvars:

    aws_region         = "ap-south-1"  # Your preferred region
    bucket_name_prefix = "your-project-bucket-"
    github_username    = "your-github-username"
    github_repository  = "your-repo-name"
  4. Deploy infrastructure

    terraform init
    terraform plan
    terraform apply
  5. Save outputs for GitHub Actions

    terraform output

πŸ”§ Local Development

Run Development Server

# Install dependencies
npm install

# Start development server
npm run dev

# Access application
open http://localhost:5173

Build for Production

# Create production build
npm run build

# Preview production build
npm run preview

Testing

# Run tests
npm test

# Run linting
npm run lint

# Type checking
npm run type-check

☁️ AWS Deployment

Manual Deployment

# Build the application
npm run build

# Deploy to S3
aws s3 sync dist/ s3://your-bucket-name --delete

# Invalidate CloudFront cache
aws cloudfront create-invalidation \
  --distribution-id YOUR_DISTRIBUTION_ID \
  --paths "/*"

Infrastructure Components

S3 Bucket Configuration

resource "aws_s3_bucket" "cloudquiz_bucket" {
  bucket_prefix = var.bucket_name_prefix
  force_destroy = true
  
  # Security configurations
  # - Block public access
  # - Server-side encryption
  # - Versioning disabled for cost optimization
}

CloudFront Distribution

resource "aws_cloudfront_distribution" "s3_cloudquiz_distribution" {
  # Global edge locations
  # HTTPS redirect enforcement
  # Optimized caching for static assets
  # Origin Access Identity for security
}

IAM Roles & Policies

# GitHub OIDC Provider for secure authentication
# IAM role for GitHub Actions
# Minimal required permissions (principle of least privilege)

πŸ”„ CI/CD Pipeline

GitHub Actions Workflow

The CI/CD pipeline automatically triggers on push to main branch:

name: Deploy to AWS S3

on:
  push:
    branches: [ main ]

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read
    
    steps:
    - name: Checkout code
    - name: Setup Node.js
    - name: Install dependencies
    - name: Build React app
    - name: Configure AWS credentials (OIDC)
    - name: Deploy to S3
    - name: Invalidate CloudFront cache

Required GitHub Secrets

Add these secrets in your GitHub repository settings:

Secret Name Description Example
AWS_REGION AWS deployment region ap-south-1
AWS_ROLE_TO_ASSUME IAM role ARN for GitHub Actions arn:aws:iam::123456789012:role/...
S3_BUCKET S3 bucket name cloudquiz-bucket-20240101123456
CLOUDFRONT_DISTRIBUTION_ID CloudFront distribution ID E1ABCD234567890

Pipeline Features

βœ… Automated Testing - Runs linting and type checking
βœ… Secure Authentication - Uses OIDC instead of AWS keys
βœ… Atomic Deployments - Complete deployment or rollback
βœ… Cache Invalidation - Immediate content updates
βœ… Build Optimization - Minified and optimized assets

πŸ“ Project Structure

cloud-quiz-craft/
β”œβ”€β”€ πŸ“ src/                          # React application source
β”‚   β”œβ”€β”€ πŸ“ components/               # Reusable UI components
β”‚   β”œβ”€β”€ πŸ“ pages/                    # Page components
β”‚   β”œβ”€β”€ πŸ“ hooks/                    # Custom React hooks
β”‚   β”œβ”€β”€ πŸ“ lib/                      # Utility functions
β”‚   └── πŸ“ data/                     # Static data files
β”œβ”€β”€ πŸ“ public/                       # Static assets
β”œβ”€β”€ πŸ“ terraform/                    # Infrastructure as Code
β”‚   β”œβ”€β”€ πŸ“„ main.tf                   # Main Terraform configuration
β”‚   β”œβ”€β”€ πŸ“„ variables.tf              # Input variables
β”‚   β”œβ”€β”€ πŸ“„ output.tf                 # Output values
β”‚   β”œβ”€β”€ πŸ“„ provider.tf               # Provider configuration
β”‚   └── πŸ“„ terraform.tfvars          # Variable values
β”œβ”€β”€ πŸ“ .github/workflows/            # CI/CD pipeline
β”‚   └── πŸ“„ deploy.yml                # GitHub Actions workflow
β”œβ”€β”€ πŸ“„ package.json                  # Node.js dependencies
β”œβ”€β”€ πŸ“„ vite.config.ts                # Vite configuration
β”œβ”€β”€ πŸ“„ tailwind.config.ts            # Tailwind CSS configuration
β”œβ”€β”€ πŸ“„ .gitignore                    # Git ignore rules
└── πŸ“„ README.md                     # This file

πŸ”’ Security Features

Infrastructure Security

  • Private S3 Bucket - No public access allowed
  • Origin Access Identity - Only CloudFront can access S3
  • HTTPS Enforcement - All traffic redirected to HTTPS
  • IAM Best Practices - Principle of least privilege
  • Server-Side Encryption - All files encrypted at rest

CI/CD Security

  • OIDC Authentication - No long-lived AWS credentials stored
  • Repository-specific Access - IAM role limited to specific repo
  • Secure Secrets Management - GitHub repository secrets
  • Audit Trail - All deployments logged and traceable

πŸ’° Cost Optimization

Estimated Monthly Costs (Low Traffic)

Service Estimated Cost Notes
S3 Standard $0.50 - $2.00 Based on storage used
CloudFront $0.00 - $1.00 Free tier: 1TB transfer
Route 53 $0.50 If using custom domain
Total $1.00 - $3.50 Very cost-effective

Cost Optimization Features

βœ… S3 Standard Storage - Cost-effective for frequently accessed files
βœ… CloudFront Free Tier - 1TB monthly transfer included
βœ… No EC2 Instances - Serverless architecture
βœ… Efficient Caching - Reduced origin requests
βœ… Automated Cleanup - Old build artifacts removed

πŸ“š Learning Resources

For Beginners

  1. AWS Fundamentals

  2. Terraform Learning

  3. GitHub Actions

Advanced Topics

  • AWS CDK vs Terraform comparison
  • Multi-environment deployment strategies
  • Blue-green deployments with CloudFront
  • Monitoring and alerting with CloudWatch
  • Security scanning in CI/CD pipelines

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Areas for Contribution

  • Add monitoring and alerting
  • Implement blue-green deployments
  • Add automated testing in CI/CD
  • Create Kubernetes deployment option
  • Add custom domain setup guide

πŸ“§ Contact

Vinsin Patel - AWS DevOps Engineer
πŸ“§ Email: [email protected]
πŸ’Ό LinkedIn: linkedin.com/in/vinsin21
πŸ™ GitHub: @vinsin21


πŸ“„ License

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


⭐ If this project helped you learn AWS DevOps, please give it a star! ⭐

About

AWS cirtifications practice website

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors