【问题标题】:I get "Invalid template property or properties"Template validation error: Invalid template property or properties [IPAssoc, IPAddress]"我收到“无效的模板属性或属性”模板验证错误:无效的模板属性或属性 [IPAssoc,IPAddress]”
【发布时间】:2018-09-23 14:27:18
【问题描述】:

您好,下面是我在 AWS 中创建启用了弹性 IP 的实例的模板。但是我不确定我哪里出错了。我已经通过在线 json 验证器验证了 json 仍然面临问题请帮助

{
  "AWSTemplateFormatVersion" : "2010-09-09",

  "Description" : "My learning template",
  "Parameters" : {
    "KeyName": {
        "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the web server",
        "Type": "AWS::EC2::KeyPair::KeyName",
        "Default" : "Myvirginiakey",
        "ConstraintDescription" : "must be the name of an existing EC2 KeyPair."
    },
    "EC2InstanceType" : {
      "Type" : "String",
      "Default" : "t2.micro",
      "AllowedValues" : ["t2.micro", "m1.small", "m1.large"],
      "Description" : "Enter t2.micro, m1.small, or m1.large. Default is t2.micro."
    }
  },
  "IPAddress" : {
    "Type" : "AWS::EC2::EIP"
  },
  "IPAssoc" : {
    "Type" : "AWS::EC2::EIPAssociation",
    "Properties" : {
      "InstanceId" : { "Ref" : "EC2Instance" },
      "EIP" : { "Ref" : "IPAddress" }
    }
  },
  "Resources" : {
    "Ec2Instance" : {
      "Type" : "AWS::EC2::Instance",
      "Properties" : {
       "UserData" : { "Fn::Base64" : { "Fn::Join" : [ "", [ "IPAddress=", {"Ref" : "IPAddress"}]]}},
        "KeyName" : { "Ref" : "KeyName"},
        "ImageId": "ami-0912f71e06545ad88", 
        "InstanceType" : { "Ref" : "EC2InstanceType"}
      }
    }
  },
  "Outputs" : {
  }
}

错误信息是:

“无效的模板属性或属性”模板验证错误:无效的模板属性或属性 [IPAssoc, IPAddress]”

【问题讨论】:

    标签: json amazon-web-services amazon-cloudformation


    【解决方案1】:

    您需要将IPAddressIPAssoc 放在资源 部分。你在IPAddress也有一个错字

    删除这两行并使用它:

    "Resources" : {
        "Ec2Instance" : {
            "Type" : "AWS::EC2::Instance",
            "Properties" : {
                "UserData" : { "Fn::Base64" : { "Fn::Join" : [ "", [ "IPAddress=", {"Ref" : "IPAddress"}]]}},
               "KeyName" : { "Ref" : "KeyName"},
               "ImageId": "ami-0912f71e06545ad88", 
               "InstanceType" : { "Ref" : "EC2InstanceType"}
            }
        },
        "IPAddress" : {
           "Type" : "AWS::EC2::EIP"
        },
       "IPAssoc" : {
           "Type" : "AWS::EC2::EIPAssociation",
           "Properties" : {
               "InstanceId" : { "Ref" : "Ec2Instance" },
               "EIP" : { "Ref" : "IPAddress" }
           }
       } 
    },
    

    【讨论】:

      猜你喜欢
      • 2018-12-15
      • 2019-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多