Skip to content

Latest commit

Β 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ AWS DevOps Real-Time Deployment | Dev β†’ Pre-PROD β†’ Production

AWS DevOps CI/CD Nginx License Version

AWS DevOps

πŸ“Œ Overview

This repository provides a production-ready, real-time AWS DevOps deployment pipeline designed to automate application releases across three environments:

  • Development (Dev) – Continuous integration, shell linting, and fast iteration
  • Pre-Production (Staging) – Quality assurance, security scanning, and pre-release validation
  • Production (Prod) – High-reliability deployment with zero downtime and automated rollbacks

πŸ—οΈ Architecture & Pipeline Flow

flowchart LR
    A[Git Commit] --> B[AWS CodePipeline]
    B --> C[AWS CodeBuild]
    C -->|Artifacts & Metadata| D[AWS CodeDeploy]
    D -->|ApplicationStop| E1[stop_nginx.sh]
    D -->|BeforeInstall| E2[validate_environment.sh & backup_current_deployment.sh]
    D -->|AfterInstall| E3[install_nginx.sh & apply_security_config.sh]
    D -->|ApplicationStart| E4[start_nginx.sh]
    D -->|ValidateService| E5[validate_deployment.sh]
    E5 --> F[EC2 Production Target πŸš€]
Loading

πŸ†• Version 2.1 Enhancements

βœ… CodeDeploy EC2 Lifecycle Compliance: Standardized to official lifecycle hooks (ApplicationStop, BeforeInstall, AfterInstall, ApplicationStart, ValidateService).
βœ… CodeBuild Modernization: Upgraded to Node.js 20 & Python 3.11 runtimes; eliminated invalid in-container systemctl calls in favor of static linting, YAML verification, and build metadata generation (build-info.json).
βœ… Nginx Security Hardening: Validated http context headers, rate limiting zones (limit_req_zone), buffer overflow protections, and restricted file location rules.
βœ… Multi-Distro Script Support: Scripts auto-detect and support Debian/Ubuntu (apt-get) and Amazon Linux 2023/RHEL (dnf/yum).
βœ… Automated Rollback & Backup: backup_current_deployment.sh creates compressed backups of /var/www/html with automated 5-version retention.
βœ… Modern UI & Accessibility: Glassmorphic, mobile-responsive web dashboard with real-time status indicators and JSON-LD SEO metadata.


πŸ“‹ Project Structure

β”œβ”€β”€ appspec.yml                  # AWS CodeDeploy application specification
β”œβ”€β”€ buildspec.yml                # AWS CodeBuild build specification
β”œβ”€β”€ index.html                   # Modern application dashboard
β”œβ”€β”€ nginx-security.conf          # Nginx security hardening configuration
β”œβ”€β”€ environments/                # Environment-specific configuration profiles
β”‚   β”œβ”€β”€ dev.env                 # Development environment settings
β”‚   β”œβ”€β”€ staging.env             # Staging environment settings
β”‚   └── prod.env                # Production environment settings
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ stop_nginx.sh           # Hook: ApplicationStop (graceful shutdown)
β”‚   β”œβ”€β”€ validate_environment.sh # Hook: BeforeInstall (system & resource checks)
β”‚   β”œβ”€β”€ backup_current_deployment.sh # Hook: BeforeInstall (tar.gz backup & rotation)
β”‚   β”œβ”€β”€ install_nginx.sh        # Hook: AfterInstall (multi-distro install)
β”‚   β”œβ”€β”€ apply_security_config.sh# Hook: AfterInstall (Nginx conf & permissions)
β”‚   β”œβ”€β”€ start_nginx.sh          # Hook: ApplicationStart (service startup & checks)
β”‚   β”œβ”€β”€ validate_deployment.sh  # Hook: ValidateService (end-to-end HTTP/header tests)
β”‚   └── load_environment_config.sh # Environment configuration loader utility
└── README.md                   # Project documentation

πŸ”§ Deployment Hooks Breakdown

CodeDeploy Hook Script Purpose Timeout
ApplicationStop scripts/stop_nginx.sh Gracefully stops or reloads existing Nginx instance 60s
BeforeInstall (1) scripts/validate_environment.sh Verifies disk space, memory, root permissions, network 300s
BeforeInstall (2) scripts/backup_current_deployment.sh Archives previous web directory with rotation 120s
AfterInstall (1) scripts/install_nginx.sh Idempotent package install with retry and lock management 300s
AfterInstall (2) scripts/apply_security_config.sh Applies security configs, headers, and file permissions 120s
ApplicationStart scripts/start_nginx.sh Starts Nginx, enables on boot, and verifies socket 180s
ValidateService scripts/validate_deployment.sh Validates HTTP 200, HTML body, and security headers 120s

πŸ› οΈ Configuration Management

Load environment profiles on-demand:

# Load Development Profile
./scripts/load_environment_config.sh dev

# Load Staging Profile
./scripts/load_environment_config.sh staging

# Load Production Profile
./scripts/load_environment_config.sh prod

πŸš€ Quick Start & Local Testing

Prerequisites

  • AWS Account with CodePipeline, CodeBuild, and CodeDeploy permissions
  • EC2 Instance with AWS CodeDeploy Agent installed
  • Git & Bash

Syntax & Build Dry-Run

# Verify all shell scripts
for f in scripts/*.sh; do bash -n "$f" && echo "βœ… $f valid"; done

# Verify environment profiles
for e in environments/*.env; do bash -n "$e" && echo "βœ… $e valid"; done

πŸ› οΈ Author & Credits

This project is built and maintained by Harshhaa πŸ’‘.


πŸ”– License

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

About

πŸš€ Production-ready AWS DevOps CI/CD pipeline automating multi-environment deployments (Dev βž” Staging βž” Prod) using AWS CodePipeline, CodeBuild, CodeDeploy, and hardened Nginx.

Topics

Resources

Stars

29 stars

Watchers

3 watching

Forks

Contributors

Languages