Amazon ECS and Application Auto Scaling
You can scale ECS services using target tracking scaling policies, step scaling policies, and scheduled scaling.
Use the following information to help you integrate Amazon ECS with Application Auto Scaling.
Service-linked role created for Amazon ECS
The following service-linked role is automatically created in your AWS account when registering Amazon ECS resources as scalable targets with Application Auto Scaling. This role allows Application Auto Scaling to perform supported operations within your account. For more information, see Service-linked roles for Application Auto Scaling.
-
AWSServiceRoleForApplicationAutoScaling_ECSService
Service principal used by the service-linked role
The service-linked role in the previous section can be assumed only by the service principal authorized by the trust relationships defined for the role. The service-linked role used by Application Auto Scaling grants access to the following service principal:
-
ecs.application-autoscaling.amazonaws.com
Registering ECS services as scalable targets with Application Auto Scaling
Application Auto Scaling requires a scalable target before you can create scaling policies or scheduled actions for an Amazon ECS service. A scalable target is a resource that Application Auto Scaling can scale out and scale in. Scalable targets are uniquely identified by the combination of resource ID, scalable dimension, and namespace.
If you configure auto scaling using the Amazon ECS console, then Amazon ECS automatically registers a scalable target for you.
If you want to configure auto scaling using the AWS CLI or one of the AWS SDKs, you can use the following options:
-
AWS CLI:
Call the register-scalable-target command for an Amazon ECS service. The following example registers a scalable target for a service called
sample-app-service
, running on thedefault
cluster, with a minimum task count of one task and a maximum task count of 10 tasks.aws application-autoscaling register-scalable-target \ --service-namespace ecs \ --scalable-dimension ecs:service:DesiredCount \ --resource-id service/
default
/sample-app-service
\ --min-capacity1
\ --max-capacity10
If successful, this command returns the ARN of the scalable target.
{ "ScalableTargetARN": "arn:aws:application-autoscaling:
region
:account-id
:scalable-target/1234abcd56ab78cd901ef1234567890ab123" } -
AWS SDK:
Call the RegisterScalableTarget operation and provide
ResourceId
,ScalableDimension
,ServiceNamespace
,MinCapacity
, andMaxCapacity
as parameters.
Related resources
If you are just getting started with Application Auto Scaling, you can find additional useful information about scaling your Amazon ECS resources in the following documentation:
-
Service auto scaling in the Amazon Elastic Container Service Developer Guide
-
Configuring service auto scaling in the Amazon Elastic Container Service Best Practices Guide
Note
For instructions for suspending scale-out processes while Amazon ECS deployments are in progress, see the following documentation:
Service auto scaling and deployments in the Amazon Elastic Container Service Developer Guide