7

I'm creating an ElastiCache replication group for Redis with Cloudformation, which does not allow to specify the group name or clusters name (they are randomly generated gibberish).

So my idea is to create a DNS record to alias it, but I don't know how to get the hosted zone id for the alias target.

I could go for a CNAME, but if the A record alias option is possible I would rather do that.

fortran
  • 67,715
  • 23
  • 125
  • 170
  • Check whether ["Return Value" section on this page](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-route53-hostedzone.html#d0e38557) helps. – slayedbylucifer Sep 01 '15 at 09:11
  • @slayedbylucifer I don't think it helps, that's related to create a hosted zone in the template, I need to know the hosted zone id for a dns record that I don't manage (it is generated automatically by AWS when creating the elasticache) – fortran Sep 03 '15 at 15:37
  • 1
    I agree. The ElasticCache Resource doesn't seem to return the values necessary to do a Alias (like the ElasticLoadBalancer: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-elb.html#aws-properties-ec2-elb-ref : CanonicalHostedZoneName and CanonicalHostedZoneNameID ) However, it may be worth openning a question in the aws forum. – Grady G Cooper Oct 05 '15 at 23:59
  • This is to bad that this doesn't work. – xer0x Dec 15 '16 at 21:40
  • If you set the `ReplicationGroupId`, on the `AWS::ElastiCache::ReplicationGroup`, it will use that as the clusters name. – Doug Sep 14 '17 at 00:43

1 Answers1

8

It's not currently possible to create an Alias Target to an ElastiCache Replication Group.

According to the documentation section "Choosing Between Alias and Non-Alias Resource Record Sets" (emphasis/formatting mine):

Instead of an IP address or a domain name, an alias resource record set contains a pointer to

  • a CloudFront distribution,
  • an Elastic Beanstalk environment,
  • an ELB classic or application load balancer,
  • an Amazon S3 bucket that is configured as a static website, or
  • another Amazon Route 53 resource record set in the same hosted zone.

ElastiCache is not in this list, so using a CNAME pointing to the replication group's endpoint (e.g., !GetAtt ReplicationGroup.PrimaryEndPoint.Address in your CloudFormation template) is your only option.

wjordan
  • 17,115
  • 2
  • 72
  • 91
  • 1
    the 'p' in Endpoint needs to be upper case, i.e., `!GetAtt ReplicationGroup.PrimaryEndPoint.Address` http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticache-replicationgroup.html#w2ab2c21c10d528c11 – Doug Sep 06 '17 at 19:42
  • wouldn't that be a bit risky? Is the "PrimaryEndpoint Address" guaranteed not to change in the future? I would be cautious to go down that road. – David Mar 13 '18 at 11:56