cloudformation 上的 HoztedZone 错误

HoztedZone error on cloudformation

我正在使用 cloudformation 创建一个 ecs 容器并将这个新容器添加到 route53 主机区。 但是当我 运行 这个脚本时,我遇到了 HostedZone 标签的问题

此处错误

    A client error (ValidationError) occurred when calling the CreateStack operation: Invalid template parameter property 'Properties'

这里是json

 "Parameters" : {

"InstanceType" : {
  "Description" : "Container Instance type",
  "Type" : "String",
  "Default" : "t2.medium",
  "AllowedValues" : [ "t2.micro", "t2.small", "t2.medium", "m3.medium", "m3.large", "m3.xlarge", "m3.2xlarge" ],
  "ConstraintDescription" : "must be a valid EC2 instance type."
},

"HostedZone" : {
  "Type": "AWS::Route53::HostedZone",
  "Properties": {
    "HostedZoneConfig": {
      "Comment": "My hosted zone for example.com"
    },
    "Name": "***.couchbase.com",
    "VPCs": [
      {
        "VPCId": "*********",
        "VPCRegion": "eu-west-1"
      }
    ],
    "HostedZoneTags": [
      {
        "Key": "Name",
        "Value": "Couchbase DNS"
      }
    ]
  }
    }
  },
        "Resources" : {
"ContainerInstance" : {
  "Type": "AWS::EC2::Instance",
  "Properties": {
    "Tags": [{
      "Key" : "Name",
      "Value" : "Couchbase-1"
      },
      {
        "Key" : "Type",
        "Value" : "ECS-Couchbase"
      }],
    "IamInstanceProfile" : { "Ref" : "ECSIamInstanceProfile" },
    "ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" },
      { "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
    "InstanceType"   : { "Ref" : "InstanceType" },
    "SecurityGroups" : [ "ssh","default", "couchbase" ],
    "KeyName"        : { "Ref" : "KeyName" },
    "UserData"       : { "Fn::Base64" : { "Fn::Join" : ["", [
      "#!/bin/bash -xe\n",
      "echo ECS_CLUSTER=", { "Ref" : "ClusterName" },
      " >> /etc/ecs/ecs.config\n"
    ]]}}
  }
},

"CouchbaseDNSRecord" : {
  "Type" : "AWS::Route53::RecordSet",
  "Properties" : {
    "HostedZoneName" : {
      "Fn::Join" : [ "", [
        { "Ref" : "HostedZone" }, "."
      ] ]
    },
    "Comment" : "DNS name for my instance.",
    "Name" : {
      "Fn::Join" : [ "", [
        {"Ref" : "ContainerInstance"}, ".",
        {"Ref" : "AWS::Region"}, ".",
        {"Ref" : "HostedZone"} ,"."
      ] ]
    },
    "Type" : "A",
    "TTL" : "900",
    "ResourceRecords" : [
      { "Fn::GetAtt" : [ "ContainerInstance", "PublicIp" ] }
    ]
  }
},

HostedZone 应该在 Resources 部分内。

"Parameters" : {

    "InstanceType" : {
    ...
    }

},

"Resources" : {

    "HostedZone" : {
    ... 
    },

    "ContainerInstance" : {
    ...
    },

    ...
}

您要使用 Cloudformation 创建的所有资源都应该在资源部分中。这样可以更好地剖析模板,http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html