【问题标题】:Windows spot instance with persistence request using cloudformation使用 cloudformation 的具有持久性请求的 Windows spot 实例
【发布时间】:2022-12-07 13:22:21
【问题描述】:

当我尝试使用此模板启动 Windows Server 时,出现错误:

Property validation failure: [Value of property {/LaunchTemplateData} does not match type {Object}]

我使用了这个模板:

Parameters:
  1InstanceType:
    Type: String
    Default: t2.small
    AllowedValues:
      - t2.small
      - m3.medium
      - m3.xlarge
      - i3.xlarge
  2SecurityGroup:
    Type: 'AWS::EC2::SecurityGroup::Id'
  3KeyName:
    Type: 'AWS::EC2::KeyPair::KeyName'
  4LatestAmiId:
    Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
    Default: /aws/service/ami-windows-latest/Windows_Server-2016-English-Full-Base

Resources:
  Ec2LaunchTemplate:
    Type: AWS::EC2::LaunchTemplate
    Properties:
      LaunchTemplateName: WindowsDesktop
      LaunchTemplateData:
      - ImageId: !Ref 4LatestAmiId
        InstanceType: !Ref 1InstanceType
        SecurityGroups:
          - GroupId: !Ref 2SecurityGroup
        KeyName: !Ref 3KeyName
        InstanceMarketOptions:
          MarketType: spot
          SpotOptions:
            SpotInstanceType: persistent
            InstanceInterruptionBehavior: stop

类似的代码适用于 linux 服务器。似乎无法使用 cloudformation 创建具有持久性请求的 Windows spot 实例(或模板)。

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    该错误意味着您的 LaunchTemplateData 不是对象,但在您的情况下它是一个列表。这是因为在 ImageId 之前有额外的 -。所以应该是:

    Resources:
      Ec2LaunchTemplate:
        Type: AWS::EC2::LaunchTemplate
        Properties:
          LaunchTemplateName: WindowsDesktop
          LaunchTemplateData:
            ImageId: !Ref 4LatestAmiId
            InstanceType: !Ref 1InstanceType
            SecurityGroups:
              - GroupId: !Ref 2SecurityGroup
            KeyName: !Ref 3KeyName
            InstanceMarketOptions:
              MarketType: spot
              SpotOptions:
                SpotInstanceType: persistent
                InstanceInterruptionBehavior: stop
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-04
      • 1970-01-01
      • 1970-01-01
      • 2019-12-18
      • 1970-01-01
      • 2012-07-19
      • 2014-01-17
      • 1970-01-01
      相关资源
      最近更新 更多