如何指定我的 Elastic Beanstalk 应用程序只需要 Spot 实例?

How can I specify that I only want Spot Instances for my Elastic Beanstalk application?

我的 env.yaml 有:

  aws:ec2:instances:
    InstanceTypes: g4dn.xlarge,c5.4xlarge,r5.2xlarge,r5a.xlarge
    EnableSpot: true
    SpotMaxPrice: "0.15"

但是当我eb create时,它仍然会问我:

Would you like to enable Spot Fleet requests for this environment?
(y/N): y
Enter a list of one or more valid EC2 instance types separated by commas (at least two instance types are recommended).
(Defaults provided on Enter):

为什么不尊重 env.yaml 文件?

要指定您不想要任何按需实例,您可以使用 SpotFleetOnDemandBase and SpotFleetOnDemandAboveBasePercentage:

  • SpotFleetOnDemandBase:随着您的环境扩展,您的 Auto Scaling 组 在考虑 Spot 实例 之前提供的最小按需实例数。

  • SpotFleetOnDemandAboveBasePercentage:按需实例 作为您的 Auto Scaling 组在 SpotOnDemandBase 实例之外提供的额外容量的一部分的百分比。

选项的使用在Example 2中举例说明。具体来说,如果两个选项都设置为0,则不会使用按需实例。