How aliabbasjaffri/ecs-terraform-terragrunt works
What this project is (type + purpose)
This repo is Infrastructure-as-Code for deploying a containerized Ghost “API” service on AWS ECS Fargate, fronted by an Application Load Balancer (ALB), inside a dedicated VPC + subnets, with the intent to support autoscaling (mentioned in README; may or may not be fully implemented in the Terraform modules).
• Terraform (terraform/…) defines reusable modules for AWS resources.
• Terragrunt (terragrunt/…) supplies environment-specific configuration, wiring, dependency ordering, and “run-all apply” orchestration.
Terraform modules (the “building blocks”)
Located under terraform/:
• vpc_subnet_module/: VPC, subnets, routing, internet gateway (per README).
• ecs_cluster/: ECS cluster (for Fargate).
• aws_alb/: Application Load Balancer (listeners/target groups likely here).
• ecs_application/: ECS service/task definition that runs the Ghost container and registers with ALB target group.
Each module has main.tf, variables.tf, outputs.tf → that implies explicit inputs/outputs and therefore explicit module-to-module coupling (e.g., ALB module outputs a target group ARN; ECS app consumes it).
Terragrunt live configuration (the “assembly + environment”)
Located under terragrunt/:
• base-infrastructure/dev/...: environment “dev” for foundational resources:
• vpc_subnet_module
• ecs_cluster
• aws_alb
• applications/dev/ecs_application: application layer deployed into the base infra.
• stage.hcl, root-config.hcl, terragrunt.hcl: shared settings, remote state, providers, common locals, etc.
This layout strongly suggests two tiers:
ECS Tasks → response back through ALB → client
Also add:
Control-plane (deployment and infra wiring)
• Terragrunt (as orchestrator) → Terraform modules (apply order / dependencies)
• ecs_application module depends on outputs from:
• ecs_cluster (cluster ARN/name)
• aws_alb (target group ARN, listener rules, security group IDs)
• vpc_subnet_module (subnet IDs, VPC ID)
• service_role (role ARNs)
Architectural patterns/design principles to highlight
• Layering: base-infrastructure vs application deployments (Terragrunt directories reflect this).
• Module boundaries: each AWS concern is isolated as a Terraform module with explicit variables/outputs.
• Environment isolation: dev is a full, dedicated environment; can be replicated to staging/prod via additional terragrunt folders.
• Immutable-ish deployments: ECS task definitions/services encourage replaceable tasks rather than in-place server mutation.
What technologies to label prominently
• Terraform modules: vpc_subnet_module, aws_alb, ecs_cluster, ecs_application, service_role
• AWS services: VPC, Subnets, IGW, ALB, ECS (Fargate), IAM
Diagramming conventions (what I expect you to include)
• “routes traffic to”
• “registers targets”
• “assumes role”
• “reads outputs”
Don’t overthink it: split into many components
Given the repo’s intent, “best” means you explicitly separate:
• VPC vs subnets vs routing/IGW
• ALB vs listener vs target group
• ECS cluster vs service vs task definition vs running tasks
• IAM service/task roles
• Terragrunt live config vs Terraform modules