此实例类型当前不支持虚拟化类型为 'hvm' 的非 Windows 实例:[AWS Cloudformation]

Non-Windows instances with a virtualization type of 'hvm' are currently not supported for this instance type : [AWS Cloudformation]

我正在尝试使用 cloudformation 创建一个 t2.micro 与亚马逊 linux 作为 os 的 ec2 实例。以下是 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。请解释为什么会这样?

"InstanceType" 属性在资源的属性部分中丢失。因此,它可能采用不支持“HVM”虚拟化类型的默认实例类型 (m1.small)。我遇到了类似的问题,通过添加实例类型属性修复了它。 此外,'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"},
    ....
    ....
    ....
}

以防有人在尝试构建 Packer ami 时遇到此错误。 确保您的模板文件以加壳程序扩展名命名,而不是 json.

例如,"packer build template.json" 因

而失败

Error launching source instance: InvalidParameterCombination: Non-Windows instances with a virtualization type of 'hvm' are currently not supported for this instance type. status code: 400, request id:

而 packer build template.packer 工作得很好。