-1

My question is that, I have 2 regions in AWS. One is the source region of ec2-instance and other is the target region for that ec2-instances.

In a Disaster Recovery project, when I am doing failover then ec2-instance spin up in target region with new IP (due to application availability hostname is static).

And I need to point the hostname to new IP address, now I want to point old hostname with new IP using any API/SDK, lambda function, basically I want to do this pointing job with automation.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343

1 Answers1

1

You can use Route 53 for this with AWS CLI (or other programming languages):

Boto3 Python:

import boto3

myNewIP = "X.X.X.X"
client = boto3.client("route53")
client.change_resource_record_sets(
    HostedZoneId="your.domain.com",
    ChangeBatch={
       "Comment": "Updating DNS to new host IP",
       "Changes": [
            {
                "Action": "UPSERT",
                "ResourceRecordSet": {
                    "Name": "www.your.domain.com",
                    "Type": "A", #A for IP
                    "ResourceRecords": [
                        {
                            "Value": myNewIP
                        }
                    ]
                    "TTL": 60
                }
            }
       ]
    }
)

For more information check this link Boto3 or AWS CLI.

Raul Barreto
  • 979
  • 5
  • 9