我正在尝试用amazon linux创建一个t2.micro ec2实例作为os使用cloudformation。以下是json文件(重要的部分)。
"FileName" :{
"Type" : "String",
"Default" : "cf-file.sh",
"AllowedValues": [ "cf-file.sh"]
},
"InstanceType" : {
"Description" : "WebServer EC2 instance type",
"Type" : "String",
"Default" : "t2.micro",
"AllowedValues" : ["t2.micro"],
"ConstraintDescription" : "must be a valid EC2 instance type."
},
"AMIID" :{
"Type": "String",
"Default":"ami-1ecae776",
"AllowedValues":["ami-1ecae776"]
}
},
"Resources" : {
"EC2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"UserData" : {
"Fn::Base64" : {
"Fn::Join" : [
"",
[
"#!/bin/bash\n",
"yes y | yum install dos2unix\n",
"touch ",{ "Ref" : "FileName" },"\n",
"chmod 777 ",{ "Ref" : "FileName" },"\n"
]
]
}
},
"KeyName" : { "Ref" : "KeyName" },
"ImageId" : { "Ref" : "AMIID" }
}
},
当我运行此文件时,我收到以下错误
Non-Windows instances with a virtualization type of 'hvm' are currently not supported for this instance type
我猜这个错误来自于我们使用t1系列实例类型,但我使用的是t2.micro。请解释为什么会这样?
答案 0 :(得分:21)
“ InstanceType ”属性。因此,它可能采用不支持“ HVM ”虚拟化类型的默认实例类型(m1.small)。我遇到了类似的问题,通过添加Instance Type属性修复了它。 此外,' t2.micro '实例类型不支持实例存储根设备。 请参阅下面的示例代码段以供参考:
"Parameters":{
"ServerKeyName":{
"Description" :"key pair to connect to Server",
"Type": "AWS::EC2::KeyPair::KeyName"
},
"InstanceType" : {
"Description" : "Type of EC2 instance to launch",
"Type" : "String",
"Default" : "t2.micro"
},
....
....
}
....
....
"Properties" : {
"KeyName" : { "Ref" : "ServerKeyName" },
"Tags" : [
{
"Key" : "Name",
"Value" : "test Server"
}],
"ImageId" : { "Ref" : "InstanceAMI" },
"InstanceType" : { "Ref" : "InstanceType"},
....
....
....
}
答案 1 :(得分:0)
如果有人在尝试构建Packer ami时遇到此错误。 确保您的模板文件以包装器扩展名命名,而不是以json命名。
例如," packer build template.json"
失败了启动源实例时出错:InvalidParameterCombination:虚拟化类型为' hvm'的非Windows实例目前不支持此实例类型。状态代码:400,请求ID:
而packer build template.packer工作得很好。