In Part 2, we launched EC2 and installed Nginx + PHP-FPM. Now let's add the data layer: managed MySQL, object storage, and Redis cache — all via Console.
RDS MySQL 8.0
Step 1: Create DB Subnet Group
- Search → "RDS" → click RDS
- Left menu → Subnet groups → Create DB subnet group
| Setting |
Value |
| Name |
laravel-db-subnet |
| Description |
Private subnets for Laravel RDS |
| VPC |
laravel-production-vpc |
| AZs |
ap-northeast-1a, ap-northeast-1c |
| Subnets |
Both private subnets |
Step 2: Create RDS Instance
- RDS → Databases → Create database
- Standard create
| Section |
Setting |
Value |
| Engine |
Engine type |
MySQL |
|
Version |
8.0.x (latest) |
| Template |
|
Production |
| Settings |
DB instance identifier |
laravel-mysql |
|
Master username |
admin |
|
Master password |
Strong password |
| Instance |
DB instance class |
db.t3.micro |
| Storage |
Type |
gp3 |
|
Allocated |
20 GB |
|
Autoscaling |
✅ Enable, max 100 GB |
| Availability |
Multi-AZ |
Yes |
| Connectivity |
VPC |
laravel-production-vpc |
|
Subnet group |
laravel-db-subnet |
|
Public access |
No |
|
Security group |
laravel-rds-sg |
| Additional |
Initial database name |
laravel |
|
Backup retention |
7 days |
|
Encryption |
✅ Enable |
|
Deletion protection |
✅ Enable |
- Create database → wait 5-10 minutes
Step 3: Get Endpoint
RDS → Databases → laravel-mysql → Connectivity & security → copy Endpoint.
DB_CONNECTION=mysql
DB_HOST=laravel-mysql.xxxx.ap-northeast-1.rds.amazonaws.com
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=admin
DB_PASSWORD=YOUR_STRONG_PASSWORD
Step 5: Test Connection
sudo dnf install -y mariadb105
mysql -h laravel-mysql.xxxx.ap-northeast-1.rds.amazonaws.com -u admin -p -e "SELECT VERSION();"
S3 Bucket
Step 1: Create Bucket
- Search → "S3" → Create bucket
| Setting |
Value |
| Name |
your-app-laravel-storage (globally unique) |
| Region |
ap-northeast-1 |
| Object Ownership |
ACLs disabled |
| Block Public Access |
✅ Block ALL |
| Versioning |
Enable |
| Encryption |
SSE-S3 (AES-256) |
composer require league/flysystem-aws-s3-v3
FILESYSTEM_DISK=s3
AWS_DEFAULT_REGION=ap-northeast-1
AWS_BUCKET=your-app-laravel-storage
# No AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY needed!
# IAM role provides credentials automatically.
ElastiCache Redis
Step 1: Create Subnet Group
- Search → "ElastiCache" → left menu → Subnet groups → Create
| Setting |
Value |
| Name |
laravel-redis-subnet |
| VPC |
laravel-production-vpc |
| Subnets |
Both private subnets |
Step 2: Create Redis Cluster
- ElastiCache → Redis caches → Create Redis cache
| Setting |
Value |
| Cluster mode |
Disabled |
| Name |
laravel-redis |
| Node type |
cache.t3.micro |
| Replicas |
0 |
| Subnet group |
laravel-redis-subnet |
| Security group |
laravel-redis-sg |
- Create → wait 3-5 minutes
CACHE_STORE=redis
SESSION_DRIVER=redis
QUEUE_CONNECTION=redis
REDIS_HOST=laravel-redis.xxxx.cache.amazonaws.com
REDIS_PASSWORD=null
REDIS_PORT=6379
Database Backup to S3
sudo mkdir -p /opt/scripts
sudo vim /opt/scripts/backup-db.sh
#!/bin/bash
set -euo pipefail
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BACKUP_FILE="/tmp/laravel_backup_${TIMESTAMP}.sql.gz"
mysqldump \
-h laravel-mysql.xxxx.ap-northeast-1.rds.amazonaws.com \
-u admin -p"${DB_PASSWORD}" \
--single-transaction --routines --triggers \
laravel | gzip > "${BACKUP_FILE}"
aws s3 cp "${BACKUP_FILE}" "s3://your-app-laravel-storage/backups/db/"
rm -f "${BACKUP_FILE}"
sudo chmod +x /opt/scripts/backup-db.sh
Series Navigation: