I recently had to migrate a Rails application hosted on Heroku from US-East to EU-West. Heroku provides some decent documentation on the process here but I ran into a few gotchas and I thought I’d share my experience.
Here’s a little background. In general I use Heroku to deploy most of my web applications. Heroku is a platform as a service (PaaS) provider hosted on Amazon EC2. While I am experimenting with provisioning my own EC2 instances and leveraging Amazon RDS for running a Postgres database, for now Heroku is my primary choice for hosting web applications. Why?
- I can deploy my apps in seconds with the Heroku CLI.
- I mostly build Ruby apps and Heroku is optimised for Ruby.
- My dev-ops commitment is minimised so I can focus on building features.
- The vast majority of my apps work happily on the free tier.
- The new dyno types will allow me to implement background processing on the free tier.
- I may need more control over a hosting environment in the future, but for now, Heroku does me just fine.
So why the need to move AWS region? Well, by default, when you deploy an application to Heroku it automatically assigns it to the US-East region unless you explicitly specify the –region eu flag. I wasn’t concerned about this at first, until it came to integrating S3 file storage. My application users are primarily based in Ireland and the UK so when setting up an S3 bucket I obviously chose EU West so as to minimise latency for my end users. Then it clicked. AWS offer free data transfer out of S3 to EC2 instances within the same region. Heroku runs on EC2. My application does some post processing of images following upload to S3 so there would be some data transfer required. I needed my Heroku deployment to be in EU-West. So here is how I did it.