Http Hobo

Another blog with web-development tips’n’tricks. | About me

Transferring Amazon EC2 instance to another region

Recently we have launched an AWS EC2 instance in Canada Central region and created a S3 storage to use with it. We couldn’t connect to the storage and while investigation it appeared that AWS SDK for PHP v2 seems to be not compatible with this region – it worked well with US East region well though.

So we decided to move both instance and storage to US East region. With S3 it was pretty easy for us – we had no data there yet, so just dropped the bucket and created another one in US East.

With EC2 instance it’s a bit more tricky – we had a configured server with installed software and we didn’t want to reinstall everything on another instance, so we needed a transfer. Transfer of the instance itself is not possible, but you can transfer AMI – Amazon Machine Image.

An Amazon Machine Image (AMI) provides the information required to launch an instance, which is a virtual server in the cloud. You specify an AMI when you launch an instance, and you can launch as many instances from the AMI as you need. You can also launch instances from as many different AMIs as you need.

Seems pretty clear. Now here are quite simple steps on how to do the transfer:

  1. Stop an instance in order to ensure data integrity there – you don’t want create an image in the middle of some operation which might lead to data corruption, and risk of that is quite high if the instance is working.
  2. Choose the instance and go to menu Actions -> Image -> Create Image. Give it some name, ensure all the instance’s volumes are there and create AMI.
  3. After some time go to the list of your AMIs and you will see a freshly created one. Choose it and go to menu Actions -> Copy AMI. Choose destination region and start copying. Don’t forget to switch region in the console in order to find destination AMI.
  4. When AMI in destination region becomes available, choose it and go to menu Actions -> Launch. Then just launch an instance as usual – you will have to set up all instance options as for the blank new instance. Note that you will have to define security group there again, also Elastic IP can’t be transferred, so in case of using it on the old instance, you’ll just have to allocate a new IP for the new instance.

That’s it! When you connect to the instance, you will find out all the software and data is there. Don’t forget to do a clean up – AMI, old instance, old volume, etc, also change IP addresses pointing to the old instance, e. g. DNS records.

You can read AWS documentation on AMI transfer here.

Picture from

2017   aws   ec2