I recently migrated from Heroku to AWS.
it was fairly easy to configure a maintenance page and turn on the maintenance mode during an upgrade or downtime. Run a command to put site in maintenance mode.
- heroku maintenance:on –app
- Create a static page in S3 or any other cloud service and configure heroku to use it.
out of the box solution that I could use was not available. I decided to do set this up using Route 53 WRR. I was already using Route 53 which is Amazon’s DNS Service, so this was as simple as adding another Record Set. Assuming you have already setup Route 53 with the main Record Set and are creating a second record set for the maintenance site.
Steps I took:
- Create a new AWS EC2 instance.
- Install Apache.
- Update the index.html with the maintenance message.
- Create an Elastic IP and assign to the instance.
- Create a Type A record Set Set Alias to No Set Value to the IP address in Step 4. Set ID and weight & Save.
- Record Set 1: Main record set pointing to Elastic Load balancer. Set the weight to 1.
- Record Set 2: Second record set pointing to Maintence IP Address. Set the weight to 0, to prevent traffic to it.
- Record Set 1: Main record set pointing to Elastic Load balancer. Set the weight to 0.
- Record Set 2: Second record set pointing to Maintence IP Address. Set the weight to 1.
It take about 5 minutes or so to take effect.
To make this repeatable/scalable
- I should image the Ec2 instance so I can recreate this maintenance server quickly.
- I should write a script to do this toggling using Amazon api’s, rather then doing it manually each time. The script should be something like