Application Auto Scaling adjusts the number of running ECS tasks based on CloudWatch metrics or a schedule. The service module enables autoscaling by default and creates anDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/terraform-aws-modules/terraform-aws-ecs/llms.txt
Use this file to discover all available pages before exploring further.
aws_appautoscaling_target, aws_appautoscaling_policy, and optionally aws_appautoscaling_scheduled_action resources.
The service module always ignores
desired_count. Once autoscaling is active, the number of tasks is controlled by Application Auto Scaling, not Terraform. See Managing desired count externally for the workaround when autoscaling is disabled.Default behavior
Autoscaling is enabled by default (enable_autoscaling = true) with the following defaults:
| Input | Default | Description |
|---|---|---|
autoscaling_min_capacity | 1 | Minimum number of tasks. |
autoscaling_max_capacity | 10 | Maximum number of tasks. |
autoscaling_policies | CPU + memory target tracking | Default policies applied automatically. |
ECSServiceAverageCPUUtilization— scales out when average CPU across tasks exceeds the target.ECSServiceAverageMemoryUtilization— scales out when average memory across tasks exceeds the target.
Custom autoscaling policies
Override or extend the default policies by providing aautoscaling_policies map. Each key names the policy:
Scheduled scaling actions
Useautoscaling_scheduled_actions to pre-scale the service before predictable traffic changes (for example, before business hours):
schedule field accepts:
cron(...)— a cron expression in UTC or the specifiedtimezone.rate(...)— a rate expression such asrate(5 minutes).at(...)— a one-time action at a specific UTC timestamp.
| Field | Required | Description |
|---|---|---|
min_capacity | Yes | Minimum number of tasks during this action. |
max_capacity | Yes | Maximum number of tasks during this action. |
schedule | Yes | Cron, rate, or at expression. |
start_time | No | ISO 8601 timestamp when the action starts being active. |
end_time | No | ISO 8601 timestamp when the action stops being active. |
timezone | No | IANA timezone for the cron expression. Defaults to UTC. |
Suspending scaling activities
You can temporarily suspend specific scaling processes without removing the policies:| Field | Default | Description |
|---|---|---|
dynamic_scaling_in_suspended | false | Suspend scale-in actions from dynamic (target tracking) policies. |
dynamic_scaling_out_suspended | false | Suspend scale-out actions from dynamic policies. |
scheduled_scaling_suspended | false | Suspend all scheduled scaling actions. |
Disabling autoscaling
Setenable_autoscaling = false to disable autoscaling entirely. No aws_appautoscaling_target or policies will be created:
desired_count you set in Terraform controls the initial number of tasks. However, because the service module always ignores desired_count in subsequent applies (to avoid conflicts with autoscaling), any changes to desired_count in Terraform will not be applied to the running service after the first creation.
Managing desired count externally
Becausedesired_count is always ignored by the module’s lifecycle rules, changes to the number of running tasks must be made outside of Terraform when autoscaling is disabled. One approach is a null_resource that calls the AWS CLI:
desired_count value in the triggers block to trigger the CLI call on the next terraform apply. This pattern is equivalent to the EKS desired size hack.
This workaround requires the AWS CLI to be installed on the machine running Terraform. It also requires appropriate IAM permissions to call
ecs:UpdateService.Task set scale
When using an external deployment controller with task sets, the equivalent ofdesired_count is the task set scale attribute. The service module ignores scale in the same way it ignores desired_count. To update scale externally:

