How do I view and manage scheduled scaling actions for Amazon ECS services?

3 minute read
0

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, you can use the Amazon ECS console or the AWS CLI.

Note that to use the AWS CLI to configure scheduled scaling actions, you must 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 0 \
  --max-capacity 0

Note: Replace ecs-cluster with your cluster name and service-name with your service name.

To view and modify all scheduled scaling actions in the Amazon ECS console, complete the following steps:

  1. Open the Amazon ECS console.
  2. Choose the Service auto scaling tab.
  3. Under Scheduled actions, in the Actions dropdown list, select View, Edit, or Delete.

To use the AWS CLI to create a new scheduled scaling action or modify an existing 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 use the AWS CLI 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 use the AWS CLI 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 you can unregister 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.

AWS OFFICIAL
AWS OFFICIALUpdated 18 days ago