Automated deployment with high scalability, data persistence, security, and load balancing using AWS, Docker, WordPress, and MySQL.
The Problem: Traditional web hosting often fails under variable traffic loads and lacks data persistence when instances are terminated. Manually managing servers, databases, and file synchronization is inefficient and prone to downtime.
The Solution: A fully decoupled and elastic architecture on AWS. By separating the application layer (EC2), the database (RDS), and the file system (EFS), we ensure that the WordPress site can scale horizontally via Auto Scaling while maintaining a single, consistent state across all nodes.
- Features
- Service Infrastructure
- Configuration Steps
- Final Results
- Docker & User Data
- Security Considerations
- Contact
- Elastic Environment: Horizontal scaling with Auto Scaling Group.
- File Persistence: Shared persistent storage using Amazon EFS.
- Managed Database: High-performance persistence with Amazon RDS (MySQL).
- Traffic Distribution: Seamless load balancing via Elastic Load Balancer (ALB).
- Zero-Touch Deployment: Automated setup via User Data initialization scripts.
- Granular Security: Orchestrated Security Groups following the principle of least privilege.
- Custom VPC
- 2 Public Subnets (EC2 + Load Balancer)
- 2 Private Subnets (EFS + RDS)
- Amazon EC2
- Docker Compose running WordPress.
- Launch Template for automated scaling.
- Amazon RDS (MySQL)
- Managed database for WordPress core data.
- Amazon EFS
- Shared persistent storage for
/wp-content.
- Shared persistent storage for
- Elastic Load Balancer (ALB)
- Single entry point for external web traffic.
- Auto Scaling Group
- Dynamic fleet management (Min: 1, Desired: 2, Max: 3).
- Configured public subnets for instances and Load Balancer.
- Configured private subnets for EFS and RDS.
- ALB SG:
- Inbound: All traffic -> 0.0.0.0/0
- EC2 SG:
- Inbound SSH (22) -> Developer IP only.
- Inbound HTTP (80) -> Restricted to ALB SG.
- Inbound NFS (2049) -> Restricted to EFS SG.
- RDS SG:
- Inbound MySQL (3306) -> Restricted to EC2 SG only.
- EFS SG:
- Inbound NFS (2049) -> Restricted to EC2 SG.
- Named and initialized within the custom VPC.

- Mount targets configured for private subnets using the EFS SG.

- Engine: MySQL (Free Tier template).
- Connectivity: Deployed in private subnets with access restricted to the EC2 security group.

The instances are provisioned using a script that:
- Installs Docker/Containerd.
- Mounts the EFS volume.
- Launches the WordPress container with RDS environment variables.
- Creates a non-root 'devuser' for security.
🔗 Script Link:
userData.sh
- Defines the AMI (Ubuntu), Key Pair, and the automated User Data script to be used by the Auto Scaling Group.
- Configured with a specific Health Check path to ensure application availability:
/wp-admin/images/wordpress-logo.svg
- Acts as the entry point, distributing traffic across public subnets to the healthy instances in the Target Group.
- Dynamic fleet management integrated with the Load Balancer.
- Desired Capacity: 2 instances.
The project is fully autonomous. Traffic is routed through the Load Balancer DNS, ensuring access even if individual instances are terminated or replaced.
Persistence Test: 1. Upload an image via WordPress. 2. Terminate the active instance. 3. Wait for Auto Scaling to provision a new node. 4. Verify the image is still available via the new instance. (Success = EFS & RDS working correctly).
The User Data script automatically prepares the environment and mounts the network file system.
🔗 Link to user_data.sh: user_data.sh
- Isolation: No EC2 instance has direct public exposure; traffic is filtered through the ALB.
- Least Privilege: Security Groups act as virtual firewalls between layers (Web, DB, Storage).
- Non-Root Access: Implementation of
devuserfor Docker operations. - Data Integrity: Shared EFS ensures no data loss during horizontal scaling.

