In my previous article , I have explained How you can Migrate the EC2 Instances from one AWS region to the Another , Refer here

Let’s say you want to migrate the EC2 Instance and you want to run your applications in another AWS account.

in this guide , We are going to see how we can migrate the existing EC2 instance to another AWS account.

Related Articles

Create EC2 Instance using AWS Console

Launch EC2 instances from Launch template

Monitor and Auto-recover repaired EC2 Instances

Change EC2 Instance type

Create AMI from existing EC2 Instances

Sharing an AMI

  • We can share the AMI with the particular AWS account without the need of making the AMI public.
  • You can share the AMI that has the EBS volume unencrypted.
  • If the EBS is encryped with Customer managed keys , Then we should also share the CMK to the target account.
  • If the EBS volume is encrypted with AWS managed keys , then we cannot share the AMI.
  • When an AMI is shared from a particular region (Example : Singapore) , The AMI will be copied to the same region in the target AWS account.

Process of Migrating to Another account

In order to move or migrate the EC2 instance , We need to ,

  • Create AMI from existing EC2 instance
  • Granting AMI permission to Target account
  • Grant permission to the Snapshots

Step 1:

First step is to create an AMI form the existing EC2 Instance. I have explained in details for the AMI creation.

Refer here.

Step 2:

Once the AMI is created in the Source account , We need to grant permission for the target account so that the AMI will be shared.

Login to the EC2 console , and then Click AMI in the left navigation pane.

Choose the AMI which you have created in the Step 1.

Under Actions , and then Click Modify Image Permissions

EC2

Provide the AWS Account Number (target aws account) and click Add permission.

if you want to share with multiple AWS accounts , Repeat the same process.

Check Add “create volume” permission to following associated snapshots

Then Click Save.

Step 3 : Verification

Now Go to the target AWS account. Choose the same region from where the AMI is shared from the Source AWS account.

Login to EC2 console and then Choose AMI ,

Then select Private images , You should be able to see the AMI here.

EC2

Important Note

  • Once the AMI is shared by source account , If the Source AWS account removes the Target AWS Account id from the Manage Image permission , The AMI will automatically be deleted from the Target AWS account.Because the AMI is still owned by the source AWS account.
  • Hence the AMI cannot be Deregister or Manage Image permission by the target aws account.
EC2
  • In order to avoid that , We need to Copy AMI or Launch Instance from the AMI so that the AMI can be owned by target aws account.
  • To copy AMI ,

Under Actions , select Copy AMI

Select the destination region where the AMI should be copied and click Copy AMI

EC2

Conclusion

We have learnt how we can migrate an EC2 instances to another AWS account and how we can overcome the challenges during this process.

Hope you find it helpful. Thanks for reading this article.

Please check my other articles.