Turning on Amazon ECS cluster auto scaling
You turn on cluster auto scaling so that Amazon ECS manages the scaling of Amazon EC2 instances that are registered to your cluster.
If you want to use the console to turn on Cluster auto scaling, see see Creating a capacity provider for Amazon ECS.
Before you begin, create an Auto Scaling group and a capacity provider. For more information, see Amazon ECS capacity providers for EC2 workloads.
To turn on cluster auto scaling, you associate the capacity provider with the cluster, Then you turn on cluster auto scaling.
-
Use the
put-cluster-capacity-providerscommand to associate one or more capacity providers with the cluster.To add the AWS Fargate capacity providers, include the
FARGATEandFARGATE_SPOTcapacity providers in the request. For more information, seeput-cluster-capacity-providersin the AWS CLI Command Reference.aws ecs put-cluster-capacity-providers \ --clusterClusterName\ --capacity-providersCapacityProviderNameFARGATE FARGATE_SPOT \ --default-capacity-provider-strategy capacityProvider=CapacityProvider,weight=1To add an Auto Scaling group for EC2, include the Auto Scaling group name in the request. For more information, see
put-cluster-capacity-providersin the AWS CLI Command Reference.aws ecs put-cluster-capacity-providers \ --clusterClusterName\ --capacity-providersCapacityProviderName\ --default-capacity-provider-strategy capacityProvider=CapacityProvider,weight=1 -
Use the
describe-clusterscommand to verify that the association was successful. For more information, seedescribe-clustersin the AWS CLI Command Reference.aws ecs describe-clusters \ --clusterClusterName\ --include ATTACHMENTS -
Use the
update-capacity-providercommand to turn on managed auto scaling for the capacity provider. For more information, seeupdate-capacity-providerin the AWS CLI Command Reference.aws ecs update-capacity-provider \ --nameCapacityProviderName\ --auto-scaling-group-provider "managedScaling={status=ENABLED}"