I want to view and manage the scheduled scaling actions for my Amazon Elastic Container Service (Amazon ECS) services.
Resolution
Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.
Use service auto scaling to schedule the minimum and maximum task count for an Amazon ECS service at a specific time. To configure service auto scaling, use the Amazon ECS console or the AWS CLI.
To use the AWS CLI to configure scheduled scaling actions, first register the Amazon ECS service as a scalable target. To check whether a scalable target exists for an Amazon ECS service, run the following describe-scalable-targets command:
aws application-autoscaling describe-scalable-targets \
--service-namespace ecs \
--resource-id service/ecs-cluster/service-name
Note: Replace ecs-cluster with your cluster name and service-name with your service name.
If the Amazon ECS service doesn't have a scalable target, then run the following register-scalable-target command to add one:
`aws application-autoscaling register-scalable-target \ --service-namespace ecs \ --scalable-dimension ecs:service:DesiredCount \ --resource-id service/ecs-cluster/service-name \ --min-capacity minimum-task-count \ --max-capacity maximum-task-count`
Note: Replace ecs-cluster with your cluster name and service-name with your service name. Also, replace minimum-task-count with the desired minimum task count and maximum-task-count with the desired maximum task count.
To view and modify all scheduled scaling actions in the Amazon ECS console, complete the following steps:
- Open the Amazon ECS console.
- Choose your cluster, and then choose the service.
- Choose the Service auto scaling tab.
- Under Scheduled actions, in the Actions dropdown list, select View, Edit, or Delete.
To create or modify a scheduled scaling action, run the following put-scheduled-action command:
aws application-autoscaling put-scheduled-action \
--service-namespace ecs \
--scalable-dimension ecs:service:DesiredCount \
--resource-id service/ecs-cluster/service-name \
--scheduled-action-name action-name \
--scalable-target-action MinCapacity=minimum-count,MaxCapacity=maximum-count \
--schedule "schedule"
Note: Replace ecs-cluster with your cluster name, service-name with your service name, and action-name with the scheduled action name. Also, replace minimum-count with the minimum task count, maximum-count with the maximum task count, and schedule with a rate, cron, or at expression.
To view a scheduled action, run the following describe-scheduled-actions command:
aws application-autoscaling describe-scheduled-actions \
--service-namespace ecs \
--resource-id service/ecs-cluster/service-name
Note: Replace ecs-cluster with your cluster name and service-name with your service name.
To delete a scheduled action, run the following delete-scheduled-action command:
aws application-autoscaling delete-scheduled-action \
--service-namespace ecs \
--scalable-dimension ecs:service:DesiredCount \
--resource-id service/ecs-cluster/service-name \
--scheduled-action-name action-name
Note: Replace ecs-cluster with your cluster name, service-name with your service name, and action-name with the scheduled action name.
If you delete all scheduled actions for an Amazon ECS service, then deregister the service as a scalable target. Run the following deregister-scalable-target command:
aws application-autoscaling deregister-scalable-target \
--service-namespace ecs \
--resource-id service/ecs-cluster/service-name \
--scalable-dimension ecs:service:DesiredCount
Note: Replace ecs-cluster with your cluster name and service-name with your service name.