AWS CloudFormation Create Route 53 Private Hosted Zone

amazon-cloudformationamazon-route53amazon-vpc

Hello and thanks in advance…

I'm leveraging AWS CloudFormation to automatically build up a VPC and Subnets etc.

I would like the CloudFormation template to create a Route 53 Private Hosted Zone for VPC, but it appears that the only option is to create Public Hosted Zones. The syntax for public zones is as follows (within "Resources"):

"MyHostedZone": {
    "Properties": {
        "HostedZoneConfig": {
            "Comment": "Created by CloudFormation"
        },
        "Name": "subdomain.example.com"
    },
    "Type": "AWS::Route53::HostedZone"
}

Ref: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-route53-hostedzone.html#cfn-route53-hostedzone-name

I've read the API docs for creating a hosted zone, and it seems that the endpoint to create a Public & Private Hosted Zone are the same, but the differentiating factor being that creating a Private Hosted Zone includes a VPC ID and a Region.

Does anyone have a suggestion on how to create a Private Hosted Zone using CloudFormation? I noticed that CloudFormation has the ability to create a "Custom Resource" but the docs are relatively confusing.

  • Is there a way to do it?
  • Or, is making a Custom Resource the way to go? If so, can you help build the Resource JSON that would call the correct API endpoint?

Thanks!!

Best Answer

I've been waiting for this too. Looks like it was added a couple of weeks after your post, you can find more information in this article

"DNS": {
  "Type": "AWS::Route53::HostedZone",
  "Properties": {
    "HostedZoneConfig": {
      "Comment": "My hosted zone for example.com"
    },
    "Name": "example.com",
    "VPCs": [{
      "VPCId": "vpc-abcd1234",
      "VPCRegion": "ap-northeast-1"
    },
    {
      "VPCId": "vpc-efgh5678",
      "VPCRegion": "us-west-2"
    }],
    "HostedZoneTags" : [{
      "Key": "SampleKey1",
      "Value": "SampleValue1"
    },
    {
      "Key": "SampleKey2",
      "Value": "SampleValue2"
    }]
  }
}