Deploy a containerised application on AWS Fargate front‑ended by an Application Load Balancer (ALB) with a single module call. The module creates (or re‑uses) an ECS cluster, task definition, service, CloudWatch log group, target group, listener rules, security group and the required IAM roles.
## Usage Example
provider "aws" {
region = "us‑east‑1"
}
module "resume_service" {
source = "./modules/ecs‑fargate‑service" # update to your module source
# Core
aws_region = "us‑east‑1"
service_name = "resume"
environment = "prod"
# Networking
vpc_id = data.aws_vpc.main.id
subnet_ids = data.aws_subnets.private.ids
alb_securitygroup_id = aws_security_group.alb.id
http_listener_arn = aws_lb_listener.http.arn
https_listener_arn = aws_lb_listener.https.arn
domain_name = "example.com"
alb_listener_cert_arn = aws_acm_certificate.site.arn
# Image
ecr_repo_arn = aws_ecr_repository.resume.arn
ecr_repo_url = aws_ecr_repository.resume.repository_url
ecr_image_tag = "2025‑05‑15"
# Capacity
desired_count = 2
ecs_service_cpu = 512
ecs_service_memory = 1024
}## Input Variables
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| aws_region | AWS region to deploy resources | string |
n/a | yes |
| service_name | Logical name of the service (e.g. resume) |
string |
"resume" | no |
| environment | Deployment environment prefix (e.g. dev, prod) |
string |
"" | no |
| subnet_ids | Subnets where tasks run | list(string) |
n/a | yes |
| vpc_id | VPC of the service | string |
n/a | yes |
| alb_securitygroup_id | Security‑group ID of the public ALB | string |
n/a | yes |
| http_listener_arn | ALB HTTP listener ARN (port 80) | string |
n/a | yes |
| https_listener_arn | ALB HTTPS listener ARN (port 443) | string |
n/a | yes |
| domain_name | Root domain – used for the host‑header rule | string |
n/a | yes |
| alb_listener_cert_arn | ACM cert ARN to attach to the listener | string |
"" | no |
| existing_ecs_cluster_id | Provide to re‑use an existing ECS cluster | string |
"" | no |
| ecs_cluster_name | Name if the module creates a new cluster | string |
"" | no |
| desired_count | Number of tasks | number |
0 |
no |
| deployment_maximum_percent | Upper deployment surge | number |
100 |
no |
| deployment_minimum_healthy_percent | Lower deployment floor | number |
0 |
no |
| ecs_service_cpu | CPU units per task | number |
256 |
no |
| ecs_service_memory | Memory (MiB) per task | number |
256 |
no |
| ecr_repo_arn | ECR repository ARN | string |
n/a | yes |
| ecr_repo_url | ECR repository URL | string |
n/a | yes |
| ecr_image_tag | Image tag to deploy | string |
"dev" | no |
Tip – variables marked yes are required
- Shared ALB
- Route53 Hosted Zone
- ACM Certificate
- ECR Repository