How do I move my EC2 instance to another subnet, Availability Zone, or VPC?
Last updated: 2020-08-17
I want to move or copy my Amazon Elastic Compute Cloud (Amazon EC2) instance to another subnet, Availability Zone, or virtual private cloud (VPC). How do I do that?
It's not possible to move an existing instance to another subnet, Availability Zone, or VPC. Instead, you can manually migrate the instance by creating a new Amazon Machine Image (AMI) from the source instance. Then, launch a new instance using the new AMI in the desired subnet, Availability Zone, or VPC. Finally, you can reassign any Elastic IP addresses from the source instance to the new instance.
Before you begin, note the following:
- AMIs are based on Amazon Elastic Block Store (Amazon EBS) snapshots. For large file systems without a previous snapshot, AMI creation can take several hours. To decrease the AMI creation time, create an Amazon EBS snapshot before you create the AMI.
- Creating an AMI doesn't create a snapshot for instance store volumes on the instance. For information on backing up instance store volumes to Amazon EBS, see How do I back up an instance store volume on my Amazon EC2 instance to Amazon EBS?
- The new EC2 instance has a different private IPv4 or public IPv6 IP address. You must update all references to the old IP addresses (for example, in DNS entries) with the new IP addresses that are assigned to the new instance. If you're using an Elastic IP address on your source instance, be sure to attach it to the new instance
- Domain security identifier (SID) conflict issues can occur when the copy launches and tries to contact the domain. Before you capture the AMI, use Sysprep or remove the domain-joined instance from the domain to prevent conflict issues. For more information, see How can I use Sysprep to create and install custom reusable Windows AMIs?
Create a new image
- Open the Amazon EC2 console, and then choose Instances from the left navigation pane.
- Select the instance that you want to move, and then choose Actions, Instance State, Stop. This makes sure that the data is consistent between the old and new EBS volumes.
Note: You can skip this step if you're testing this procedure or if you don't want to stop or reboot your instance.
- Choose Actions, Image, Create Image.
For Image name, enter a name for the image.
For Image description, enter a description of the image.
Note: If you select No reboot on the Create Image page, then the file system integrity of the image can't be guaranteed.
- Choose Create Image.
- Under Create Image request received, choose View pending image [ID]. Wait for the Status to change from pending to available.
Note: You can also view pending images by choosing AMIs from the Images section of the navigation pane.
Launch a new instance
- Select the new AMI, and then choose Launch.
- Choose the same instance type as the instance that you want to move, and then choose Next: Configure Instance Details.
For Network, choose your VPC.
For Subnet, choose the subnet where you want to launch the new instance.
If the instance is a production instance, then for Enable termination protection, choose Protect against accidental termination.
- Choose Next: Add Storage.
- Accept the defaults, and then choose Next: Add Tags.
For Key, enter Name.
For Value, enter your instance name.
- Choose Next: Configure Security Group.
- Choose the same security group that's applied to the instance that you're moving.
Note: If you're moving your instance between VPCs, you must create a new security group on the destination VPC.
- Choose Review and Launch.
- Choose Launch.
- For Select a key pair, choose your key pair from the drop-down menu.
- Select the agreement check box, and then choose Launch Instances.
- Choose the instance ID to return to the EC2 console.
Reassign the Elastic IP address
To reassign the Elastic IP address, you must first disassociate the Elastic IP address from the source instance. Then, you can reassociate the Elastic IP address with the new instance. For instructions, see Disassociating an Elastic IP address.
Note: Elastic IP addresses can be used in only one Region. If you move an instance to a different Region, you can't use the same Elastic IP address.