【问题标题】:Cloudformation Error(Value of property Stepadjustments must be a list of objects)Cloudformation 错误(属性 Stepadjustments 的值必须是对象列表)
【发布时间】:2018-08-01 07:39:27
【问题描述】:

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

    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 Auto Scaling 最初只支持简单的扩展策略。如果您在引入目标跟踪和步进策略之前创建了扩展策略,则您的策略将被视为简单扩展策略。

enter image description here

【问题讨论】:

  • 这与问题有点无关,但是使用 cfndsl 而不是 YAML 模板有什么好处?当您在流程中添加移动部分时,这会使调试您的特定问题变得更加困难。
  • 更新为 yaml

标签: json ruby amazon-web-services yaml amazon-cloudformation


【解决方案1】:

“StepAdjustments”应该是list,而不是列表中的列表。

这是来自official documentation 的示例。

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

【讨论】:

  • 错误与此类似,谢谢,为了简单起见,我使用 cfndsl 将 ruby​​ 转换为 json,然后再转换为 yaml。在我的 ruby​​ 模板中用“方括号”替换了“方括号”。成功了
猜你喜欢
  • 1970-01-01
  • 2020-03-25
  • 1970-01-01
  • 2020-07-14
  • 2021-12-05
  • 2019-04-22
  • 2010-11-23
  • 1970-01-01
  • 2021-11-23
相关资源
最近更新 更多