OpenTofu + Terragrunt + AWS
MILU2 Infra Main
Complete AWS infrastructure for mobile game, built with OpenTofu + Terragrunt for Infrastructure as Code (IaC)
Quick Facts
| Item | Value |
|---|---|
| IaC Tool | OpenTofu 1.11.5 + Terragrunt 0.99.4 |
| Cloud | AWS |
| Primary Region | ap-northeast-1 (Tokyo) |
| Secondary Region | us-east-1 (Virginia) - CloudFront/WAF/KMS |
| AWS Profile | milu2-infra |
| Current Environments | test |
Traffic Flow
HTTPS UDP/TCP
┌──────────┐ │ │
│ Client │────┼──────────────────────────────┼─────────────┐
└──────────┘ │ │ │
▼ ▼ │
┌──────────┐ ┌─────────────┐ │
│CloudFront│ │ Global │ │
│ + WAFv2 │ │ Accelerator │ │
└────┬─────┘ └──────┬──────┘ │
│ │ │
▼ ▼ │
┌──────────┐ ┌─────────────┐ │
│ ALB │ │ NLB │ │
│(internal)│ │ (internal) │ │
└────┬─────┘ └──────┬──────┘ │
│ │ │
┌─────────┼─────────┐ │ │
▼ ▼ ▼ ▼ │
┌────────┐┌────────┐┌────────┐ ┌──────────────┐ │
│ API ││ Web ││ Admin │ │ Game Nodes │ │
│Fargate ││Fargate ││Fargate │ │ (EC2 + ECS) │ │
└────────┘└────────┘└────────┘ └──────────────┘ │System Components
1. Application Services
| Service | Technology | Purpose |
|---|---|---|
| API | PHP + Nginx | Game API server |
| Web | PHP + Nginx | Web interface |
| Admin | PHP + Nginx | Admin dashboard |
| Push | Node.js 24 | Push notification |
2. Game Node Servers (ECS on EC2)
| Server | Protocol | Purpose |
|---|---|---|
| World | UDP | World game logic |
| Commu | UDP | Community features |
| Battle | UDP | Battle system |
| Chat | TCP (Socket.io) | Real-time chat |
| Center | Internal | Central coordination |
3. Data Stores
| Service | Type | Purpose |
|---|---|---|
| RDS Aurora | MySQL 8.0 Serverless v2 | Primary database |
| ElastiCache | Valkey 8.0 | Session/cache (cluster mode) |
| MemoryDB | Valkey 7.2 | Durable cache |
| DocumentDB | v5.0 Serverless | Document storage |
4. Edge & CDN
| Service | Purpose |
|---|---|
| CloudFront | 4 distributions (web/admin/api/assets) |
| WAFv2 | Web Application Firewall |
| Global Accelerator | UDP/TCP game traffic (Custom Routing) |
Deployment Model
| Type | Method | Role |
|---|---|---|
| Infrastructure | make apply-<env> | GitHub Actions (milu2-github-actions-infra) |
| Application | CodeDeploy Blue/Green | GitHub Actions (milu2-github-actions-app-deploy) |
Quick Commands
# Start dev container make init && make up # Login to AWS make sso # Plan changes make plan-test # Apply changes make apply-test
Document Index
| Category | Documents |
|---|---|
| Architecture | 02-Infrastructure, 03-Network, 04-Security |
| Terraform Code | 05-Files, 06-Source, 07-Modules, 08-Variables |
| Deployment | 09-Deploy, 10-Env, 11-State, 12-CICD |
| Operations | 13-Runbook, 14-Troubleshoot, 15-Change |
| Security | 16-Secrets, 17-Compliance |
| Cost | 18-Cost Estimation |
| Collaboration | 19-Contribution, 20-Convention |
Getting Started
Related Documentation
Also check out MILU2 Stage Infrastructure docs (Terraform + PowerShell):
MILU2 Stage Infrastructure