How to create an route53 record of the Private IP in Cloudformation

amazon-cloudformationamazon-route53amazon-web-servicesdomain-name-system

I have a cloudformation script in AWS that creates an EC2 instance, with some firewall rules, S3 mappings and other stuff.. and I create a DNS record in route53 for the public ip of the instance, this works well.

Now I need to create another record in DNS of the internal ip of the host (for internal use, so that other instances can talk to this instance without going via the public ip).

I have not found a way to do this. is it possible? does anyone have an example cloudformation script?

Best Answer

It is possible, but you need to setup a "Private Hosted Zone", as described in this article Access an Internal Version of your Website Using the Same Domain Name | Amazon AWS Support then adapt the following cloudformation to meet your needs

"myDNSRecord2" : {
    "Type" : "AWS::Route53::RecordSet",
    "Properties" : {
        "HostedZoneId" : "Z3DG6IL3SJCGPX",
        "Name" : "mysite.example.com.",
        "Type" : "A",
        "TTL" : "900",
        "ResourceRecords" : [{
            "Fn::GetAtt" : [ "MyInstance", "PrivateIp" ]
        }]
    }
}