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.

已提問 5 年前檢視次數 839 次
1 個回答
0

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

已回答 5 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南