OpenTofu + Terragrunt + AWS

MILU2 Infra Main

Complete AWS infrastructure for mobile game, built with OpenTofu + Terragrunt for Infrastructure as Code (IaC)

Quick Facts

ItemValue
IaC ToolOpenTofu 1.11.5 + Terragrunt 0.99.4
CloudAWS
Primary Regionap-northeast-1 (Tokyo)
Secondary Regionus-east-1 (Virginia) - CloudFront/WAF/KMS
AWS Profilemilu2-infra
Current Environmentstest

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

ServiceTechnologyPurpose
APIPHP + NginxGame API server
WebPHP + NginxWeb interface
AdminPHP + NginxAdmin dashboard
PushNode.js 24Push notification

2. Game Node Servers (ECS on EC2)

ServerProtocolPurpose
WorldUDPWorld game logic
CommuUDPCommunity features
BattleUDPBattle system
ChatTCP (Socket.io)Real-time chat
CenterInternalCentral coordination

3. Data Stores

ServiceTypePurpose
RDS AuroraMySQL 8.0 Serverless v2Primary database
ElastiCacheValkey 8.0Session/cache (cluster mode)
MemoryDBValkey 7.2Durable cache
DocumentDBv5.0 ServerlessDocument storage

4. Edge & CDN

ServicePurpose
CloudFront4 distributions (web/admin/api/assets)
WAFv2Web Application Firewall
Global AcceleratorUDP/TCP game traffic (Custom Routing)

Deployment Model

TypeMethodRole
Infrastructuremake apply-<env>GitHub Actions (milu2-github-actions-infra)
ApplicationCodeDeploy Blue/GreenGitHub 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

CategoryDocuments
Architecture02-Infrastructure, 03-Network, 04-Security
Terraform Code05-Files, 06-Source, 07-Modules, 08-Variables
Deployment09-Deploy, 10-Env, 11-State, 12-CICD
Operations13-Runbook, 14-Troubleshoot, 15-Change
Security16-Secrets, 17-Compliance
Cost18-Cost Estimation
Collaboration19-Contribution, 20-Convention

Getting Started

Related Documentation

Also check out MILU2 Stage Infrastructure docs (Terraform + PowerShell):

MILU2 Stage Infrastructure