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
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 π]
β
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.
βββ 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
| 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 |
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- AWS Account with CodePipeline, CodeBuild, and CodeDeploy permissions
- EC2 Instance with AWS CodeDeploy Agent installed
- Git & Bash
# 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"; doneThis project is built and maintained by Harshhaa π‘.
- GitHub: @NotHarshhaa
- Blog: Hashnode
- LinkedIn: Harshhaa
This project is licensed under the MIT License - see the LICENSE file for details.
