Thursday, 30 August 2012

How to transfer Amazon EC2 instances from one account to another

OK, I have to write it down right away before I forget all the details.

Tomorrow is the last day of my Amazon AWS Free Tier, so once again, just like a year ago, I had to create a new account to keep running a micro Linux instance for free (digression: I've spent some time comparing the EC2 prices to Hetzner virtual hosting and as it turns out, it makes no sense to pay for EC2 with my demands, Hetzner will turn out to be much cheaper. However, since it's free, nothing can beat it).

Last time I've done this I actually had to manually transfer all my data to a new Linux installation. This time I thought there were better ways to do that, as I couldn't afford to waste all the time recreating all the setup over again.

So, here's what you need to do to transfer a running EBS instance to a different account:

0. Take a note of the specs of the AMI that you're using. Most important parts are the architecture (i386 or x86_64 and the aki of the kernel being used).

1. Set up a new account while still using the old one. You can even use the same credit card, all you need is a different email address.

2. There are two ways you can go here. The aim is to create a snapshot that is owned by the new account, not "rented" from the old account:
2.1. Use the old account to create a snapshot of the running AMI, then share the snapshot with the new account.
2.2. In the old account share the running AMI with the new account. Then, in the new account create a local snapshot of that AMI.

3. Either way, you should end up with a snapshot that is owned by the new account. To confirm, remove all sharing from AMIs and snapshots in the old account.

4. Open up the snapshots list in the new account and click "Create image". Set up the AMI as usual but be sure to check that architecture and the aki match those that were used before with this AMI. Otherwise, the instance will appear to have started but will not respond to any interaction.

5. Use the new AMI to start a new instance as usual.

And you're done. Now you can double check that everything is working fine and remove the snapshot which uses up the S3 space, and can easily exceed the 5GB Free Tier allowance.

1 comment: