使用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
相关产品推荐
相关产品推荐

