This documentation outlines the LAMP stack application deployment completed. The deployment follows AWS Well-Architected Framework principles with emphasis on scalability and availability.
I've configured a multi-tier network architecture to provide security and isolation:
- VPC: Created with CIDR block 10.0.0.0/16
- Subnets: Deployed across 3 Availability Zones:
- Public subnets (10.0.1.0/24, 10.0.2.0/24, 10.0.3.0/24) for load balancers
- Private app subnets (10.0.11.0/24, 10.0.12.0/24, 10.0.13.0/24) for web servers
- Private data subnets (10.0.21.0/24, 10.0.22.0/24, 10.0.23.0/24) for databases
- Route Tables:
- Public route tables with Internet Gateway access
- Private route tables with NAT Gateway for outbound traffic
- Internet Gateway: For public internet access
I've implemented defense-in-depth security measures:
- Security Groups:
- ALB Security Group: Allows HTTP/HTTPS from internet
- Web Server Security Group: Accepts traffic only from ALB
- Database Security Group: Accepts MySQL traffic only from web servers
- Network ACLs: Configured with allow/deny rules for additional network security
- IAM Roles: EC2 instances use IAM roles with minimal permissions needed
- Encryption: Data encrypted at rest and in transit
- Application Load Balancer in public subnets
- Health checks configured to monitor
/health.phpwith 30-second intervals - Sticky sessions disabled to ensure proper load distribution
- HTTPS listener with ACM-issued certificate
- Auto Scaling Group with:
- Minimum: 2 instances
- Desired: 4 instances
- Maximum: 10 instances
- Scaling policies:
- Scale out when CPU > 70% for 5 minutes
- Scale in when CPU < 30% for 10 minutes
- EC2 instances:
- t3.medium instances for cost-effective performance
- Latest Amazon Linux 2 AMI
- Spread across multiple AZs for high availability
- Amazon RDS for MySQL:
- Multi-AZ deployment for high availability
- db.t3.large instance class
- General Purpose SSD storage with 100GB initial allocation
- Automated backups with 7-day retention period
- Read replicas can be added as application scaling demands
The following installations are performed on each EC2 instance via user data script:
#!/bin/bash
sudo yum update -y
sudo yum install -y docker
sudo systemctl start docker
sudo systemctl enable docker
sudo docker pull lusitech/lamp-stack:v10
sudo docker pull lusitech/lamp-phpmyadmin:v3
sudo docker run -d -p 8080:80 --restart always --name php-app lusitech/lamp-stack:v10
sudo docker run -d -p 8081:80 --restart always --name myadb lusitech/lamp-phpmyadmin:v3I've set up comprehensive monitoring:
- CloudWatch Dashboards: Custom dashboard showing key metrics
- CloudWatch Alarms:
- High CPU Utilization (>80% for 5 minutes)
- Low free memory (<10% for 5 minutes)
- HTTP 5xx errors (>1% of requests)
- Database connections (>80% of maximum)
- CloudWatch Logs:
- Apache access and error logs
- MySQL slow query logs
- Application error logs
- Health Checks: Custom
/health.phpendpoint for deeper application monitoring
- Database Backups:
- Automated RDS snapshots daily
- Transaction logs for point-in-time recovery
- Manual snapshots before major changes
- Application Backups:
- S3 versioning enabled on code bucket
- Weekly AMI creation of properly configured instances
The infrastructure can scale in several ways:
- Horizontal Scaling: Auto Scaling Group adds/removes EC2 instances based on load
- Vertical Scaling: Instance types can be upgraded for more CPU/memory
- Database Scaling:
- Read replicas for read-heavy workloads
- Vertical scaling by changing instance class
- Aurora serverless as a future option for variable workloads
The deployment adheres to AWS Well-Architected Framework:
- Operational Excellence: Automation, monitoring, and documentation
- Security: Defense in depth with least privilege access
- Reliability: Multi-AZ deployment with automatic recovery
- Performance Efficiency: Right-sized resources with ability to scale
- Cost Optimization: Auto Scaling to match capacity with demand
- Implement AWS WAF for additional security
- Configure Route 53 for DNS management and failover
- Set up CloudFront for content delivery and caching
- Implement CI/CD pipeline with CodePipeline for automated deployments
- Review security posture regularly with AWS Trusted Advisor
