Auto Scaling
Overview
Section titled “Overview”The Express Gateway Service
The aws_ecs_express_gateway_service Terraform resource that provisions an ECS service with managed ALB, auto scaling, and simplified configuration for HTTP/HTTPS web applications and APIs. includes built-in target tracking auto scaling through the scaling_target block. Unlike classic ECS where you configure separate Application Auto Scaling resources, Express Mode handles the scaling infrastructure automatically.
The scaling_target Block
Section titled “The scaling_target Block”resource "aws_ecs_express_gateway_service" "this" { # ...
scaling_target { auto_scaling_metric = "CPU" auto_scaling_target_value = 70 min_task_count = 1 max_task_count = 3 }}Parameter Reference
Section titled “Parameter Reference”| Parameter | Type | Allowed Values | Source Repo Value |
|---|---|---|---|
auto_scaling_metric | string |
| "CPU” |
auto_scaling_target_value | number | 1–100 (percentage) | 70 |
min_task_count | number | ≥ 1 | 1 |
max_task_count | number | ≥ min_task_count | 3 |
How Target Tracking Works
Section titled “How Target Tracking Works”When you set auto_scaling_metric = "CPU" and auto_scaling_target_value = 70, Express Mode:
- Monitors average CPU utilization across all running tasks
- Adds tasks when average exceeds 70%
- Removes tasks when average drops below 70% (with cooldown)
- Maintains count between
min_task_countandmax_task_count
Express Mode vs Classic Auto Scaling
Section titled “Express Mode vs Classic Auto Scaling”Classic ECS requires multiple resources for auto scaling:
aws_appautoscaling_target— registers the service as scalableaws_appautoscaling_policy— defines the tracking policy- CloudWatch alarms — created automatically by the policy
With Express Mode, the scaling_target block replaces all of these. Express Mode also provisions the RollbackAlarm
A CloudWatch metric alarm created by Express Mode that triggers automatic deployment rollback when new tasks fail ALB health checks. that triggers deployment rollback when new tasks fail health checks.