AWS Elastic Beanstalk deployment error: InvalidParameterValue: Template does not have a numeric EvaluationPeriods setting

AWS Elastic Beanstalk deployment error: InvalidParameterValue: Template does not have a numeric EvaluationPeriods setting

我在尝试使用 .ebextensions 部署 EB 工作者应用程序时遇到错误。我的 .ebextensions:

中有两个文件

options.config:

option_settings:
  aws:elasticbeanstalk:cloudwatch:logs:
    StreamLogs: true
    DeleteOnTerminate: true
    RetentionInDays: '7'
  
  aws:ec2:instances:
    InstanceTypes: t2.micro,t3.micro

  aws:autoscaling:trigger:
    EvaluationPeriods: '1'

  aws:autoscaling:launchconfiguration:
    SecurityGroups: sg-xxxxxxxxxxxxx

  aws:autoscaling:asg:
    Cooldown: '60'
    MinSize: '0'
    MaxSize: '5'
  
  aws:elasticbeanstalk:environment:process:
    Port: '2030'

  aws:elasticbeanstalk:sqsd:
    HttpPath: '/calculate'
    HttpConnections: '1'
    MaxRetries: '1'

工人-scaling.config

Resources:
  AWSEBCloudwatchAlarmHigh:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmActions: []

  AWSEBCloudwatchAlarmLow:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmActions: []

  QueueSizeAlarmHigh:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmDescription: "Scale up when queue has more than 1 message"
      Namespace: "AWS/SQS"
      MetricName: ApproximateNumberOfMessagesVisible
      Dimensions:
        - Name: QueueName
          Value:
            "Fn::Select":
              - 4
              - "Fn::Split":
                - '/'
                - "Fn::GetOptionSetting":
                    Namespace: "aws:elasticbeanstalk:sqsd"
                    OptionName: "WorkerQueueURL"
      Statistic: Average
      Period: 60
      EvaluationPeriods: 1
      Threshold: 1
      ComparisonOperator: GreaterThanOrEqualToThreshold
      AlarmActions:
        - Ref: AWSEBAutoScalingScaleUpPolicy

  QueueSizeAlarmLow:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmDescription: "Scale down when queue has less than 1 message"
      Namespace: "AWS/SQS"
      MetricName: ApproximateNumberOfMessagesVisible
      Dimensions:
        - Name: QueueName
          Value:
            "Fn::Select":
              - 4
              - "Fn::Split":
                - '/'
                - "Fn::GetOptionSetting":
                    Namespace: "aws:elasticbeanstalk:sqsd"
                    OptionName: "WorkerQueueURL"
      Statistic: Average
      Period: 60
      EvaluationPeriods: 1
      Threshold: 1
      ComparisonOperator: LessThanThreshold
      AlarmActions:
        - Ref: AWSEBAutoScalingScaleDownPolicy

我一直在关注这个教程:https://elasticbeanstalkscaling.workshop.aws/04_scaleworkers.html

但是,在部署时我收到以下错误:

Failed to deploy application.
InvalidParameterValue: Template does not have a numeric EvaluationPeriods setting

我试图在 ebextensions 中保留尽可能多的配置,以便可以将 repo 推送到多个环境,并且它们都将以相同的方式运行。因此,在创建 EB 时,除了最低限度的默认设置外,我没有触及任何东西,据我所知,如果您在创建时 select 设置,它们将优先于 options.config 设置。

有人有什么建议吗?提前谢谢你。

事实证明答案很简单,但 AWS 的这些错误并没有让它变得显而易见。

只需将实例类型从单实例更改为负载平衡即可。这是显而易见的,因为我们在这里所做的全部工作是调整缩放的工作方式——尽管我最初的逻辑是尝试在版本控制的配置文件中保留尽可能多的配置。但是,事实证明,您无法通过配置设置 EnvironmentType,因此这只是应该在开始时执行的一个步骤。

希望这能在未来为某人节省好几个小时!