gpt4 book ai didi

json - EC2 实例类型的 AWS Cloudformation 模板错误

转载 作者:行者123 更新时间:2023-12-03 07:42:52 26 4
gpt4 key购买 nike

我尝试在 CloudFormation 模板上启用 Spot 实例选项,然后将其提取到 AWS Service Catalog 中。

我收到专门针对 InstanceMarketOptions 参数的 MarketType 参数的错误,并且似乎无法找出问题所在,因为该参数是正确的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。

关于json - EC2 实例类型的 AWS Cloudformation 模板错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61334083/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com