无法创建 ScalingPolicy - 未注册可扩展目标

Jon*_*sie 6 amazon-web-services aws-cloudformation

我已按照此处的示例进行操作,但是当我尝试更新堆栈时,出现以下错误:

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)
Run Code Online (Sandbox Code Playgroud)

我见过的所有示例和文档都显示资源 ID,如下所示:

service/cluster-name-AB678321674/service-AB672345678
Run Code Online (Sandbox Code Playgroud)

例如:https: //docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-applicationautoscaling-scalabletarget.html

我不知道如何或在哪里可以获得这种格式的资源 ID。

CF 看起来像这样:

 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
Run Code Online (Sandbox Code Playgroud)

该集群是在单独的堆栈中创建的,因此我必须导出/导入它。

有人能看到我在这里做错了什么吗?

TIA。

Jon*_*sie 1

好吧,FFS。我删除了目标,然后将目标和策略添加在一起,效果很好。