05. File List and Directory Structure
Directory and file structure of the MILU2 Infrastructure project.
Project Root
milu2_infra-main/
โโโ Makefile # ๐ฏ Main entry point - all commands here
โโโ docker-compose.yml # Dev container definition
โโโ ecs_exec.sh # ECS exec helper script
โโโ README.md # terraform-docs placeholder
โโโ .docker/ # Docker build files
โโโ ecs/ # Local artifact dump (gitignored)
โโโ shell/ # Helper shell scripts
โโโ tofu/ # ๐๏ธ Infrastructure code (main)
โโโ docs/ # ๐ Documentation (this folder)
Shell Scripts (shell/)
shell/
โโโ get_thumbprint.sh # Get GitHub OIDC thumbprint (openssl)
โโโ get_vars.sh # Download env vars from S3
โโโ plan_with_summary.sh # Plan with colored diff summary
| Script | Usage | Purpose |
|---|
| get_thumbprint.sh | Called during apply | SHA1 OIDC thumbprint |
| get_vars.sh | sh shell/get_vars.sh <env> | Fetch common_vars.hcl + env_vars.hcl |
| plan_with_summary.sh | Via make plan-* | Colorized plan output |
Tofu Directory Structure
tofu/
โโโ envs/ # ๐ Environment configurations
โ โโโ config.hcl # Global backend + provider config
โ โโโ common_vars.hcl # Shared variables (from S3)
โ โ
โ โโโ shared/ # ๐ฆ Shared stacks (env-independent)
โ โ โโโ github_provider/ # GitHub OIDC provider
โ โ โโโ cicd_infra/ # Infra deploy role
โ โ โโโ cicd_app_deploy/ # App deploy role
โ โ
โ โโโ test/ # ๐งช Test environment
โ โโโ env_vars.hcl # Test-specific variables (from S3)
โ โโโ core/ # Main infrastructure stack
โ โโโ terragrunt.hcl # Inputs for core module
โ
โโโ modules/ # ๐งฑ Terraform modules
โโโ github_provider/ # OIDC provider module
โโโ cicd/ # Infra CI/CD role module
โโโ cicd_app_deploy/ # App CI/CD role module
โโโ core/ # ๐๏ธ Main infrastructure module
โโโ core.tf # Module composition
โโโ _variables.tf # Input variables
โโโ _outputs.tf # Output values
โโโ <sub-modules>/ # Individual componentsCore Sub-Modules Detail
tofu/modules/core/
โโโ core.tf # ๐ฏ Orchestrates all sub-modules
โโโ _variables.tf # Inputs from terragrunt
โโโ _outputs.tf # Outputs to other modules/stacks
โ
โโโ security/ # ๐ KMS + WAF
โ โโโ _variables.tf
โ โโโ _outputs.tf
โ โโโ kms.tf # Multi-region KMS keys
โ โโโ waf.tf # WAFv2 ACLs + rules
โ โโโ log_group.tf # WAF log groups
โ โโโ provider.tf # Virginia provider alias
โ
โโโ network/ # ๐ VPC + networking
โ โโโ _variables.tf
โ โโโ _outputs.tf
โ โโโ vpc.tf # VPC + subnets + IGW
โ โโโ nat_gateway.tf # NAT gateway
โ โโโ security_group.tf # 14 security groups
โ โโโ endpoint.tf # VPC endpoints (9)
โ โโโ log_group.tf # VPC flow logs
โ โโโ iam.tf # Flow log IAM role
โ
โโโ bastion/ # ๐ฅ๏ธ Bastion host
โ โโโ _variable.tf
โ โโโ _outputs.tf
โ โโโ ec2.tf # EC2 instance + EIP
โ โโโ keypair.tf # SSH key pair
โ
โโโ lb/ # โ๏ธ Load balancers
โ โโโ _variable.tf
โ โโโ _outputs.tf
โ โโโ alb.tf # Internal ALB + target groups
โ โโโ nlb.tf # Internal NLB for game nodes
โ โโโ acm.tf # ACM certificates (TODO)
โ
โโโ cdn/ # ๐ CloudFront
โ โโโ _variable.tf
โ โโโ _outputs.tf
โ โโโ cloudfront.tf # 4 distributions
โ โโโ acm.tf # CloudFront ACM (Virginia)
โ โโโ log_group.tf # CDN logs
โ โโโ provider.tf # Virginia provider
โ
โโโ storage/ # ๐ฆ S3 buckets
โ โโโ _variable.tf
โ โโโ _outputs.tf
โ โโโ s3.tf # 7 buckets + lifecycle
โ โโโ iam.tf # Bucket policies
โ โโโ provider.tf # Virginia provider
โ
โโโ rds/ # ๐๏ธ Aurora MySQL
โ โโโ _variable.tf
โ โโโ _outputs.tf
โ โโโ rds.tf # Aurora cluster + instances
โ โโโ log_group.tf # RDS log groups
โ โโโ iam.tf # RDS monitoring role
โ
โโโ elasticache/ # โก ElastiCache Valkey
โ โโโ _variable.tf
โ โโโ _outputs.tf
โ โโโ elasticache.tf # Replication group
โ โโโ log_group.tf # Cache logs
โ
โโโ memorydb/ # ๐พ MemoryDB Valkey
โ โโโ _variable.tf
โ โโโ _outputs.tf
โ โโโ memorydb.tf # Cluster + ACL
โ
โโโ documentdb/ # ๐ DocumentDB
โ โโโ _variable.tf
โ โโโ _outputs.tf
โ โโโ documentdb.tf # Cluster + instances
โ โโโ log_group.tf # DocDB logs
โ
โโโ global_accelerator/ # ๐ Global Accelerator
โ โโโ _variable.tf
โ โโโ _outputs.tf
โ โโโ accelerator.tf # Custom routing accelerator
โ
โโโ lambda/ # ฮป Lambda functions
โ โโโ _variable.tf
โ โโโ _outputs.tf
โ โโโ lambda_image.tf # Image/video validators
โ โโโ lambda_cache.tf # Cache invalidator
โ โโโ lambda_ga.tf # GA port resolver
โ โโโ lambda_scale.tf # Node service scaler
โ โโโ ecr.tf # Lambda ECR repository
โ โโโ sqs.tf # Lambda trigger queues
โ โโโ sns.tf # Rekognition topic
โ โโโ log_group.tf # Lambda logs
โ โโโ iam.tf # Lambda execution roles
โ
โโโ app/ # ๐ฑ ECS applications
โโโ _variable.tf
โโโ _outputs.tf
โโโ ecs_fargate.tf # Fargate cluster + services
โโโ ecs_fargate_task.tf # Fargate task definitions
โโโ ecs_fargate_autoscale.tf # Auto scaling policies
โโโ ecs_ec2.tf # EC2 cluster + capacity
โโโ ecs_ec2_task.tf # Node task definitions
โโโ ecs_ec2_instance.tf # ASG + launch template
โโโ ecr.tf # Application ECR repos
โโโ codedeploy.tf # CodeDeploy app + groups
โโโ service_discovery.tf # Cloud Map namespace
โโโ log_group.tf # ECS log groups
โโโ iam.tf # ECS/CodeDeploy IAM rolesFile Naming Conventions
| Pattern | Purpose | Example |
|---|
| _variables.tf | Input variables | core/_variables.tf |
| _outputs.tf | Output values | core/_outputs.tf |
| _variable.tf | Sub-module inputs | rds/_variable.tf |
| *.tf | Resource definitions | vpc.tf, rds.tf |
| provider.tf | Provider configuration | security/provider.tf |
| iam.tf | IAM resources | app/iam.tf |
| log_group.tf | CloudWatch log groups | rds/log_group.tf |
Terragrunt Files
| File | Location | Purpose |
|---|
| config.hcl | envs/ | Global backend + provider |
| common_vars.hcl | envs/ | Shared app_name, region |
| env_vars.hcl | envs/<env>/ | Environment-specific vars |
| terragrunt.hcl | envs/<env>/core/ | Stack configuration |
| terragrunt.hcl | envs/shared/*/ | Shared stack configs |
Docker Files
.docker/
โโโ aws/
โโโ Dockerfile # Dev container image
# Base: amazon/aws-cli:2.33.31
# + OpenTofu 1.11.5
# + Terragrunt 0.99.4
# + crane (container tool)
# + SSM plugin
# + MariaDB clientQuick File Location Guide
| Looking for... | Location |
|---|
| All Make commands | Makefile |
| Environment variables | envs/<env>/env_vars.hcl |
| Core module inputs | envs/<env>/core/terragrunt.hcl |
| Security groups | modules/core/network/security_group.tf |
| ECS services | modules/core/app/ecs_fargate.tf |
| RDS configuration | modules/core/rds/rds.tf |
| Lambda functions | modules/core/lambda/lambda_*.tf |
| IAM roles | modules/core/app/iam.tf |
| Backend config | envs/config.hcl |