Question:
I’ve followed the example here but when I try to update my stack I get the following error:
1 2 3 4 5 |
No scalable target registered for service namespace: ecs, resource ID: service/xxx-prod/xxx-prod-api, scalable dimension: ecs:service:DesiredCount (Service: AWSApplicationAutoScaling; Status Code: 400; Error Code: ObjectNotFoundException; Request ID: 1232c749-a7a9-11e9-bd34-dfed08b14539) |
All the examples and documentation Ive seen show the resource id as something like :
1 2 |
service/cluster-name-AB678321674/service-AB672345678 |
I dont see how or where I can get the resource id in this format.
The CF looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
AutoScalingTarget: Type: AWS::ApplicationAutoScaling::ScalableTarget Properties: MinCapacity: !Ref MinContainers MaxCapacity: !Ref MaxContainers ResourceId: Fn::Join: - "/" - - service - Fn::ImportValue: !Join [':', [!Ref AppStackName, 'ClusterName']] - !GetAtt Service.Name ScalableDimension: ecs:service:DesiredCount ServiceNamespace: ecs # "The Amazon Resource Name (ARN) of an AWS Identity and Access Management (IAM) role that allows Application Auto Scaling to modify your scalable target." RoleARN: Fn::ImportValue: !Join [':', [!Ref SecurityStackName, 'AutoScaleRole']] AutoScalingPolicy: Type: AWS::ApplicationAutoScaling::ScalingPolicy Properties: PolicyName: !Join ['', [!Ref ServiceName, AutoScalingPolicy]] PolicyType: TargetTrackingScaling ScalingTargetId: !Ref AutoScalingTarget TargetTrackingScalingPolicyConfiguration: PredefinedMetricSpecification: PredefinedMetricType: ECSServiceAverageCPUUtilization ScaleInCooldown: 10 ScaleOutCooldown: 10 # Keep things at or lower than 50% CPU utilization, for example TargetValue: !Ref AutoScalingTargetValue |
The cluster is created in a separate stack so I have to export/import that.
Can anyone see what I’ve done wrong here?
TIA.
Answer:
Just ran into the same error,
Not too sure what @Jonesie means by adding them together, but there’s two ways to solve this:
Either add “DependsOn: AutoScalingTarget” to AutoScalingPolicy, so the scalable target gets created before the AutoScalingPolicy
Or use ScalingTargetId in stead of ServiceNamespace/ScalableDimension/ResourceId. By using ScalingTargetId and then !Ref AutoScalingTarget you’re setting up the dependency between the two resources, which is the actual problem 😉