Search code examples
amazon-web-servicesamazon-ecsaws-auto-scaling

What is AWS Resource Id of an ECS Service


I am trying to define a CustomizedMetricSpecification for an ECS Service using put-scaling-policy CLI command.

The command requires the resource-id of the scalable target which auto-scaling service will scale but I am not able to find the resource-id of my ECS Service.

I tried to pass the ARN of the service as resource-id but I am getting this error.

An error occurred (ObjectNotFoundException) when calling the PutScalingPolicy operation: No scalable target registered for service namespace: ecs, resource ID: arn:aws:ecs:us-east-1:XXXXXXXXXXXX:service/XYZ-SERVICE, scalable dimension: ecs:service:DesiredCount

CLI Command: aws application-autoscaling put-scaling-policy --service-namespace ecs --scalable-dimension ecs:service:DesiredCount --resource-id arn:aws:ecs:us-east-1:XXXXXXXXXXXX:service/XYZ-SERVICE --policy-name custom-scaling-policy --policy-type TargetTrackingScaling --target-tracking-scaling-policy-configuration file://custom_autoscaling_config.json

Is ARN not the correct value for resource-id field? What should I do to create the custom auto-scaling policy?


Solution

  • You can see the documentation for this here, along with an example. The expected format of the resource ID is not obvious at all. You would never know the format without finding that documentation. The expected format is a string like this:

    "service/cluster-name/service-name"

    Where service is the hard-coded literal string "service", cluster-name is the name of your ECS cluster, and service-name is the name of your ECS service.