How do I transfer an Amazon EC2 instance or AMI to a different AWS account?

4 minute read

I want to transfer an Amazon Elastic Compute Cloud (Amazon EC2) instance or Amazon Machine Image (AMI) from one Amazon Web Services (AWS) account to another. How can I do this?

Short description

It's not possible to transfer existing instances or AMIs between AWS accounts. Instead, you can manually migrate an EC2 image from one AWS account to another.


Note: The following steps apply only to instances with unencrypted Amazon Elastic Block Store (Amazon EBS) volumes.

  1. Create a custom AMI from the instance that you want to use as the source account. Be sure to include all required EBS data volumes in the AMI. Be sure that the AMI doesn't have a static IP configuration, as this can result in connectivity issues. For instructions, see one of the following:
    Create a Windows AMI from a running instance
    Create a Linux AMI from an instance
    Note: Data stored on instance store volumes isn't preserved in AMIs. This data won't be on the instance store volumes of the instances that you launch from the AMI.
  2. Share the AMI with the target account using either the Amazon EC2 console or the AWS Command Line Interface (AWS CLI). For instructions, see one of the following:
    User Guide for Windows Instances - Share an AMI with specific AWS accounts
    User Guide for Linux Instances - Share an AMI with specific AWS accounts
    Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.
  3. From the target account, find the AMI using the EC2 console or the AWS CLI.
  4. Launch a new instance from the shared AMI on the target account. To import a key pair from a previous account, see Import your own public key to Amazon EC2.
    Note: For Amazon Virtual Private Cloud (Amazon VPC) instances, the private IP address is different in the new account unless specifically set during launch.
  5. Create a custom AMI from the target account instance. It's a best practice to use this copy to avoid complications after the source account deregisters the originally shared AMI.
  6. Deregister the AMI on the source account if you don't need to run any instances from it. For information about how to terminate running instances and delete associated snapshots, see Clean up your Amazon EBS-backed AMI.

Note: If you share an AMI from account A to account B, and then deregister the AMI from account A, you can't launch new instances from the AMI in account B. You can leave the AMI registered in account A so that you can launch new instances from it later. Or, use one of the following workarounds so that you can deregister the AMI and retain the capability to launch new instances:

  • Launch new instances from the shared AMI in account B before you deregister the AMI in account A. Deregistering the AMI in the original account doesn't impact instances launched from the shared AMI. If you need to launch new instances after deregistering the AMI, you can create a new AMI from one of the new instances.
  • Copy the AMI to the same Region or a different Region in account B. This allows you to preserve the original AMI and also creates a backup without using it in account B.

Related information

How do I create an AMI in one AWS Region and then copy it to another?

How to share encrypted AMIs across accounts to launch encrypted EC2 instances

How do I share an Amazon Machine Image (AMI) privately with another AWS account?

Share an encrypted snapshot using the console - Linux

Share an encrypted snapshot using the console - Windows

AWS OFFICIALUpdated 3 years ago