You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用CloudFormation创建持久化Windows Spot Instance报错求助

问题解决:CloudFormation启动Windows Spot实例报错

错误原因

报错Property validation failure: [Value of property {/LaunchTemplateData} does not match type {Object}]的根本原因是LaunchTemplateData属性被错误定义为数组类型,CloudFormation要求该属性必须是对象类型(Object)。模板里在LaunchTemplateData:下添加了减号-,导致它被解析为数组,不符合属性类型要求。这个问题和Windows/Linux系统无关,纯粹是语法错误。

修正后的模板

移除LaunchTemplateData:下的减号-,将其内容改为对象格式:

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

额外说明

AWS支持为Windows实例创建持久化Spot请求,你模板中关于Spot配置的部分是正确的,之前的报错完全是由于LaunchTemplateData的语法错误导致的,修正后即可正常创建Windows Spot实例。

内容的提问来源于stack exchange,提问作者shantanuo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 03:55:25