![](/img/trans.png)
[英]AWS CloudFormation Template (JSON) to Create EC2 - Unexpected Error
[英]AWS Cloudformation Template Error with EC2 Instance Types
我正在尝试在我的 CloudFormation 模板上启用 Spot Instance 选项,然后将其摄取到 AWS Service Catalog。
我收到一个关于我的MarketType
参数的错误,专门针对InstanceMarketOptions
参数,并且似乎无法弄清楚问题是什么,因为该参数就在 AWS 文档中。
任何方向都会很棒。 谢谢
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Creates an EC2 instance running the Custom DATA Ubuntu Image",
"Parameters" : {
"KeyName": {
"Description" : "Name of an existing EC2 key pair for SSH access to the EC2 instance.",
"Type": "AWS::EC2::KeyPair::KeyName"
},
"SubnetId": {
"Type" : "String",
"Default" : "subnet-0b53e6d08c86dc68d",
"AllowedValues": ["subnet-0b53e6d08c86dc68d"],
"Description" : "SubnetId of an existing subnet in your Virtual Private Cloud (VPC)"
},
"SecurityGroupId": {
"Type": "String",
"Default": "sg-040b93c603129931f",
"Description":"The SecurityGroupId of an existing EC2 SecurityGroup in your Virtual Private Cloud (VPC)"
},
"InstanceType" : {
"Description" : "EC2 instance type.",
"Type" : "String",
"Default" : "m5.large",
"AllowedValues" : [ "m5.large","m5.xlarge","m5.2xlarge"," m5.4xlarge","m5.8xlarge","m5.12xlarge","m5.16xlarge","p2.xlarge"]
},
"InstanceMarketOptions" : {
"Description" : "EC2 Spot Instance",
"MarketType" : "spot"
},
"SSHLocation" : {
"Description" : "The IP address range that can SSH to the EC2 instance.",
"Type": "String",
"MinLength": "9",
"MaxLength": "18",
"Default": "10.0.0.0/8",
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
"ConstraintDescription": "Must be a valid IP CIDR range of the form x.x.x.x/x."
}
},
"Metadata" : {
"AWS::CloudFormation::Interface" : {
"ParameterGroups" : [{
"Label" : {"default": "Instance configuration"},
"Parameters" : ["InstanceType", "MarketType"]
},{
"Label" : {"default": "Security configuration"},
"Parameters" : ["KeyName", "SSHLocation"]
}],
"ParameterLabels" : {
"InstanceType": {"default": "Server size:"},
"KeyName": {"default": "Key pair:"},
"SSHLocation": {"default": "CIDR range:"},
"MarketType": {"default": "Spot:"}
}
}
},
"Mappings" : {
"AWSRegionArch2AMI" : {
"us-east-1" : { "HVM64" : "ami-xxxxxxxxxxxx" }
}
},
"Resources" : {
"EC2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"InstanceType" : { "Ref" : "InstanceType" },
"SecurityGroupIds" : [ { "Ref" : "SecurityGroupId" } ],
"KeyName" : { "Ref" : "KeyName" },
"MarketType" : {"Ref" : "InstanceMarketOptions" },
"SubnetId" : { "Ref" : "SubnetId" },
"ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, "HVM64" ] }
}
}
},
"Outputs" : {
"PrivateDNSName" : {
"Description" : "Private DNS name of the new EC2 instance",
"Value" : { "Fn::GetAtt" : [ "EC2Instance", "PrivateDnsName" ] }
},
"PrivateIPAddress" : {
"Description" : "Private IP address of the new EC2 instance",
"Value" : { "Fn::GetAtt" : [ "EC2Instance", "PrivateIp" ] }
}
}
}
MarketType 不是您可以为AWS::EC2::Instance设置的属性
与我认为您正在寻找的最接近的是AWS::EC2::LaunchTemplate LaunchTemplateData和 InstanceMarketOptions。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.