When you have a set of application servers running in EC2 in an active/passive configuration, the easiest way to failover is to simply update the DNS to point to the second server as soon as it's available to serve requests. If you are using Route 53 to manage your DNS configuration, with the AWS CLI you can make this change in a single command.
- Install the AWS CLI
- Login with an account that has an IAM Policy that gives it access to the Route53 Service
- Get the HostedZoneID for the domain you want to update from the AWS console here: https://console.aws.amazon.com/route53/home#hosted-zones:
The CLI expects the change to be submitted via a JSON-formatted configuration file. I've included a short example in this gist that just updates the cname. For a full list of options available, check out the AWS Command Line reference
Assuming the the CLI is properly configured and a change file called change-cname.json
file in your current working directory:
aws route53 change-resource-record-sets --hosted-zone-id [[HostedZoneID]] --change-batch file://change-cname.json