Skip to main content
Move AWS EC2

How to move AWS EC2 Instance from one account to another

At KnackForge, besides Development Services we assist Clients to setup server and take the responsibility of ensuring that their sites and servers are running smooth without any (or least) securely compromise.

We have tried different hosting providers ranging from shared host like bluehost to fully managed infrastructure providers like Amazon Web Services (AWS). AWS has been the best of our choices this far and we prefer the same for hosting clients site.
 
 
 
While this blog title say moving of instance, technically we are not moving the instance, instead we are creating a snapshot of existing server (in the form of AMI) and with the same we setup a new instance in different account. The steps involved in this process has been explained in this post.
 
What is Amazon AMI?
An Amazon Machine Image (AMI) is a special type of pre-configured operating system and virtual application software which is used to create a virtual machine within the Amazon Elastic Compute Cloud (EC2). It serves as the basic unit of deployment for services delivered using EC2. 
See https://aws.amazon.com/amis for more details about it.
 
Login to AWS console of account from which you want to move the instance, navigate to "Instances" pane. Right click on the instance to be moved and choose "Create Image (EBS AMI)". Once done, you will receive a status message saying that request received and being processed to create image.
 
Navigation Pane in AWS Console
 
 
Menu we see on right clicking in the instance
 
Now check the "AMI" pane. You will see an AMI being created, when the status turns from "Pending" to "Available". You need to edit its permissions to be able to use from another AWS account.
 
Popup to change AMI permission
 
Enter the account id of the AWS account to which you want to expose this AMI. To find the account id; See "My Account / console > Security Credentials".
 
Now switch to the another account's AWS console. Navigate to "Instances" pane. Click the "Launch Instance" button, follow "Classic wizard", in the "Community AMIs" tab, search by entering the AMI id. A sample id will look like "ami-abcd1234". 
 
Tip: If for some reason you couldn't get the AMI listed in search result, try repeating the steps again or change the AMI permission to Public at the worst case. 
 
Once the AMI is listed, you could follow on from here with the usual steps of Launching instance. In a few minutes you will have your server up and running. 
 
In my case the instance i had to move had a Web server running Drupal site powered by Ubuntu.
 
As a follow up of this process, I had to open up the http, ssh and other needed ports. Also had to create an Elastic IP and bind the same to newly Launched instance.
 
Finally from domain registrar admin panel I had to change the DNS settings to use the new Elastic IP. 
 
With this approach in a less than a couple of hours I was able to get my server switched form one account to another and start running as expected with least down time.

Comments

Hi, Thanks for the post.
1. I was able to move one instance from one account to another making the AMI public, however if I make it private I am unable to see it in the community AMI's.

2. I have another AMI which I can not make it public( I got this error when I tried to make it public 'Modifying permissions failed for the following resources: ami-xxxxxxxx. Images with marketplace product codes may not be made public.') and now I want to move this image to another account. please help me how to do the same.

What if i'll delete the source AMI or shutdown the source EC2 after getting destination server running? Does it'll create any trouble or what will happen?
I want to know cause we as developers we have created server on our account and now we have to start it running on the client's account. What's the procedure if this is not the one? Help me out with your suggestion.

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.