How do I transfer an Amazon EC2 instance to a different AWS account?
Last updated: 2019-08-29
I want to transfer an Amazon Elastic Compute Cloud (Amazon EC2) instance from one Amazon Web Services (AWS) account to another. How can I do this?
It's not possible to transfer existing instances between AWS accounts. Instead, you can manually migrate an EC2 image from one AWS account to another. First, create an Amazon Machine Image (AMI) based on the original EC2 instance from the source account. Then, share the AMI with the target account, and launch a new instance based on that AMI from the target account. Finally, create your own copy of the AMI on the target account to begin using it on the different account.
To share or migrate an EC2 image from a source account to a target account, follow these steps:
Note: The following steps apply only to instances with unencrypted Amazon Elastic Block Store (Amazon EBS) volumes.
- 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 does not have a static IP configuration, as this can result in connectivity issues.
Note: Data stored on instance store volumes isn't preserved in AMIs, and won't be on the instance store volumes of the instances that you launch from the AMI.
For instructions, see Creating a Windows AMI from a Running Instance or Creating a Linux AMI from an Instance.
- Share the AMI with the target account using either the Amazon EC2 console or the AWS Command Line Interface (AWS CLI).
- From the target account, find the AMI using the EC2 console or the AWS CLI.
- Launch a new instance from the shared AMI on the target account. To import a key pair from a previous account, see Importing Your Own Public Key to Amazon EC2.
Note: For Amazon Virtual Private Cloud (Amazon VPC) instances, the private IP address will be different in the new account unless specifically set during launch.
- 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.
- If you don't need to run any instances of this Amazon EBS-backed AMI on the source account, clean up your AMI. For information about how to terminate running instances and delete associated snapshots, see Cleaning up your Amazon EBS-backed AMI.
Note: After you deregister an AMI, you can't use it to launch new instances. Be sure that the account that you've shared your AMI with is running the instances that they need before you deregister your AMI. You can also opt to leave the AMI registered so that you can launch new instances from it later.