Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudFormation Route53 - Update an existing RecordSet

I am trying to write a BLUE/GREEN CFT that tears down and rebuilds the EC2 Instances, ELB and Update the Route53 record Alias with this updated DNS name of this ELB.

If the Alias Record DOESNT exist, I'm able to create the Alias Record Set correctly after the EC2 instances are created and the ELB attaches these instances. But If the recordset exists with the old ELB DNS Name, the CFT is failing with "Alias RecordSet exists". Naturally - am looking to UPDATE this record with the updated ELB DNS name on running the full CFT. Any suggestions?

    "HostRecord" : {
    "Type" : "AWS::Route53::RecordSet",
    "Properties" : {
    "HostedZoneName" : "REDACTED",
    "Comment" : "Updates the ELB DNS name into Route 54 recordset.",
    "Name" : "REDACTED",
    "Type" : "A",
    "AliasTarget" : {
        "DNSName" : { "Fn::GetAtt" : [ "ESClusterELB" , "DNSName" ] },
        "HostedZoneId" : { "Fn::GetAtt" : [ "ESClusterELB" , "CanonicalHostedZoneNameID" ] }
    }
like image 370
Dorian McAllister Avatar asked Oct 21 '25 21:10

Dorian McAllister


1 Answers

Managing a single resource (such as a RecordSet) from 2 different CloudFormation stacks is not supported.

I have a few recommandations for your use-case:

  1. I recommend you manage the record independently from the templates that you're using for blue/green. Once green is created/updated and you want your record to resolve for the green ELB, you can just update the stack that govern the RecordSet, setting it to the appropriate alias.
  2. Using the same base as the first suggestion. You could automate this using the SNS notification triggered by CloudFormation when a stack is created/updated. Using this in conjunction with a Lambda you could dynamically update the stack that controls the RecordSet.
  3. You could create a custom resource that solely serve the purpose of updating the record set to the wanted alias.
like image 142
Laurent Jalbert Simard Avatar answered Oct 24 '25 16:10

Laurent Jalbert Simard