代码之家  ›  专栏  ›  技术社区  ›  rotwar

Cloudformation错误(属性Stepadjustments的值必须是对象列表)

  •  1
  • rotwar  · 技术社区  · 7 年前

    当我尝试启动堆栈时,不断出现此资源创建错误

        ServiceScalingPolicyIn:
        Properties:
          PolicyName: StepDown
          PolicyType: StepScaling
          ScalingTargetId:
            Ref: ServiceScalingTarget
          StepScalingPolicyConfiguration:
            AdjustmentType: ChangeInCapacity
            Cooldown: '300'
            MetricAggregationType: Average
            StepAdjustments:
            - - MetricIntervalLowerBound: '0'
                ScalingAdjustment:
                  Ref: TasksCount
        Type: AWS::ApplicationAutoScaling::ScalingPolicy
    
    CPUAlarmScalein:
        Properties:
          EvaluationPeriods: '1'
          Statistic: Average
          Threshold: '25'
          AlarmDescription: Alarm if CPU usage is lower, this will always be
          Period: '300'
          AlarmActions:
          - Ref: ServiceScalingPolicyIn
          Namespace: AWS/ECS
          Dimensions:
          - Name: ClusterName
            Value: ECS365-sandbox
          - Name: ServiceName
            Value: ECSService365
          ComparisonOperator: LessThanThreshold
          MetricName: CPUUtilization
        Type: AWS::CloudWatch::Alarm
    

    我尝试调整更改

    ServiceScalingTarget:
    DependsOn: ECSService365
    Properties:
      MaxCapacity: '10'
      MinCapacity: '1'
      ResourceId:
        Fn::Join:
        - ''
        - - service/
          - Ref: Cluster365
          - "/"
          - Fn::GetAtt:
            - ECSService365
            - Name
      RoleARN:
        Fn::GetAtt:
        - AutoscalingRole
        - Arn
      ScalableDimension: ecs:service:DesiredCount
      ServiceNamespace: ecs
    Type: AWS::ApplicationAutoScaling::ScalableTarget
    

    完整堆栈链接 https://github.com/manideep444/cloudformations/blob/master/365sandbox.yml AWS文件: Amazon EC2自动缩放最初只支持简单的缩放策略。如果在引入目标跟踪和步骤策略之前创建了缩放策略,则您的策略将被视为简单的缩放策略。

    enter image description here

    1 回复  |  直到 7 年前
        1
  •  2
  •   Sudharsan Sivasankaran    7 年前

    “逐步调整”应为 list ,而不是列表中的列表。

    以下是 official documentation .

    StepAdjustments: 
          - 
            MetricIntervalLowerBound: "0"
            MetricIntervalUpperBound: "50"
            ScalingAdjustment: "1"
          - 
            MetricIntervalLowerBound: "50"
            ScalingAdjustment: "2"