paul
paul

Reputation: 13481

HoztedZone error on cloudformation

I´m using cloudformation to create a ecs container and add this new container into route53 hostzone. But when I run this script I´m having problems with the HostedZone tags

Here The error

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

Here the 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" ] }
    ]
  }
},

Upvotes: 0

Views: 129

Answers (2)

Nitin AB
Nitin AB

Reputation: 538

All the resources you want to create using Cloudformation should be within the resources section. This gives a better anatomy of the template, http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html

Upvotes: 0

Céline Aussourd
Céline Aussourd

Reputation: 10654

The HostedZone should be inside the Resources section.

"Parameters" : {

    "InstanceType" : {
    ...
    }

},

"Resources" : {

    "HostedZone" : {
    ... 
    },

    "ContainerInstance" : {
    ...
    },

    ...
}

Upvotes: 3

Related Questions