AWS CloudFormation模板(JSON)创建EC2-意外错误

时间:2019-06-10 17:13:38

标签: json amazon-ec2 amazon-cloudformation

开始测试Cloud Formation模板以使用JSON格式创建EC2实例,并出现错误“每个参数对象必须包含Type成员”。我无法在网络上找到解决方案。

我已经搜索了此错误,发现的唯一解决方案是在模板中添加“ Type”:“ String”,但是已经存在了。

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "EC2 CloudFormation Template - Version 1.0",
    "Metadata": {},
    "Parameters": {
      "InstanceType": {
        "Description": "EC2 instance type",
        "Type": "String",
        "Default": "t2.small",
        "AllowedValues": [
          "t1.micro",
          "t2.nano",
          "t2.micro",
          "t2.small",
          "t2.medium",
          "t2.large",
        ],
        "ConstraintDescription": "must be a valid EC2 instance type."
    },
    "Mappings": {

    },
    "Conditions": {

    },
    "Resources": {
      "EOTSS_EC2": {
          "Type": "AWS::EC2::Instance",
          "Properties": {
              "DisableApiTermination": "false",
              "ImageId": "ami-06bee8e1000e44ca4",
              "InstanceType": { "Ref": "InstanceType" },
              "Monitoring": "true",
              "Tags": [
                  {
                      "Key": "Name",
                      "Value": "test"
                  }
              ]
            }
          }
      },
      "Outputs": {

      }
    }
}

将其作为新堆栈启动时遇到的错误是“模板格式错误:每个Parameters对象都必须包含Type成员。”

1 个答案:

答案 0 :(得分:2)

问题是您的模板嵌套不好:Outputs应该在EOTSS_EC2之外,并且Resources应该在{{1}的同一级别},AWSTemplateFormatVersionDescriptionMetadataParametersMappingsConditions

Resources
相关问题