How to Copy, Move or Share Amazon EC2 Instance to another Amazon Account?

If you are Cloud Professional who is managing multiple AWS accounts, you may need to move your existing Amazon EC2 instance from one to another AWS Account. Thanks to the way how AWS IaaS operates, you do not need to create a new EC2 instance from scratch, but you can create an AMI image based on an existing EC2 instance and move it to a proper AWS account. One of the similar requests that you may also experience is moving your Amazon EC2 instances to different security groups, availability zone, or regions.

Amazon EC2 instance

Today we gonna walk you the procedure of transferring the Amazon EC2 instance from one to another AWS account. The instance is t2.micro and it is hosted in AWS Frankfurt. We will keep the same instance settings, but in case you need to do additional configuration, you can do it based on your needs.

Step 1: Export an Amazon EC2 instance from Source Amazon Account

In the first step, we will create an AMI image by using the existing Amazon EC2 instance, and then we will grant access to another AWS account and export key pair to be able to log into the moved Amazon EC2 instance.

  1. Login into AWS Management Console. Click on Services and then click on EC2
  2. Click on Running instances and then Right-click on Amazon EC2 instance and then click Image > Create image
  3. Define the image name and image description and then click on Create Image to generate the AMI. Additional you can select No reboot. When enabled, Amazon EC2 does not shut down the instance before creating the image. When this option is used, file system integrity on the created image cannot be guaranteed.
  4. Create an Image request received. It will take a few minutes until it is created and available. Click on View pending image ami-xxxxxxxxx.

You can access an AMI also by clicking on Images > AMIs on the left side of the window.

  1. Once it is available, right-click on the AMI image and then click Modify Image Permissions.
  2. Under Modify Image Permissions choose he image type (public or private), type the AWS Account Number, and then select Add “create volume” permissions to the following associated snapshots when creating permissions. In our case, we will choose a private image.

The AWS Account Number (known as Account ID) can be found if you click on your profile at the top right side and then click on My Account.

  1. Click on Add Permission and then click on Save. Your AMI image is successfully shared with another AWS account.

You will get an email with confirmation from AWS that your validation was successful.

Export Public Key from Existing Key Pair

Now we will export the public key from your existing key pair, so you can connect to your moved Amazon EC2 instance. In order to do it, you will need access to your private key pair. This procedure can be done on the local Windows machine by using PuTTY. PuTTY is an SSH and telnet client, developed originally by Simon Tatham for the Windows platform.

  1. Open an Internet browser and download PUTTY from this link.
  2. Click on Start and search for PuTTYGen and run it.
  3. Click on Load. Add your private key pair (*.pem). As you can see, the key is successfully imported. Please click on OK and copy the key from the field Public key for pasting into OpenSSH authorized_keys file. We will need this key in step 2.

Step 2: Import an Amazon EC2 Instance to target Amazon Account

In the second step, we will launch Amazon EC2 instance from a shared AMI image and then we will import the public key to be able to log into the Windows machine.

  1. Login into AWS Management Console
  2. Click on Services and then open EC2. Then click on Key pairs
  3. Click on Actions and then Import key pair
  4. Enter the key pair name and add the public key you copied in the previous step.
  5. Click on Import key pair and then click on IMAGES > AMI on the left side of the window
  6. Choose the Private images to access the shared AMI image
  7. Right-click on the AMI Image and click on Launch
  8. Choose an Instance Type and click Next: Configure Instance Details. We should choose the same instance type as in the source AWS account. In our case, we will choose t2.micro (Variable ECUs, 1 vCPUs, 2.5 GHz, Intel Xeon Family, 1 GiB memory, EBS only)
  9. Configure Instance Details to suit your requirements and then click Review and Launch. We do recommend enabling termination protection. You can protect instances from being accidentally terminated. Once enabled, you won’t be able to terminate this instance via the API or the AWS Management Console until termination protection has been disabled.
  10. Please review your instance launch details and click Launch. You can go back to edit changes for each section.
  11. Select the imported key pair by clicking on Choose an existing key pair and selecting the key pair.
  12. Select I acknowledge that I have access to the selected private key file (KeyPair.pem) and that without this file, I won’t be able to log into my instance and click Launch Instances.
  13. Your instances are now launching. Click on View launches.
  14. Please wait a few minutes until your instance is successfully initialized.
  15. Right-click on the image and then choose Connect
Kevin Arrows
Kevin is a dynamic and self-motivated information technology professional, with a Thorough knowledge of all facets pertaining to network infrastructure design, implementation and administration. Superior record of delivering simultaneous large-scale mission critical projects on time and under budget.

Expert Tip

How to Copy, Move or Share Amazon EC2 Instance to another Amazon Account?

If the issue is with your Computer or a Laptop you should try using Restoro which can scan the repositories and replace corrupt and missing files. This works in most cases, where the issue is originated due to a system corruption. You can download Restoro by clicking the Download button below.

Download Now

I'm not interested