Can't create ScalingPolicy - No scalable target registered

0

I've followed the example https://github.com/1Strategy/fargate-cloudformation-example/blob/master/fargate.yaml but when I try to update my stack I get the following error:

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 :

service/cluster-name-AB678321674/service-AB672345678
e.g.: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-applicationautoscaling-scalabletarget.html

I dont see how or where I can get the resource id in this format.

The CF looks like this:

 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
      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
        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.

asked 5 years ago807 views
1 Answer
0

Removing the target then re-adding the target and policy fixed the problem.

answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions