How to Move Amazon EC2 Instance to a Different Availability Zone, Virtual Private Cloud or a Region (CLI Scripts Included)


Moving Amazon EC2 instance to another Availability Zone, VPC or AWS Region may result in a headache for administrators, who think that it is a must to stop the existing and brand a new instance each time. If it’s a production instance, the interruption disrupts the working process and leads to the significant money/time losses. So, do you really have to migrate all data manually?

The answer is “no”, if you know how to properly use AWS native tools.  In this article we explain how to easily move working Amazon EC2 instance to different Availability Zone, VPC or AWS Region.

Let’s get started from the step one.

Test your AWS knowledge CTA

Step 1: Create an AMI

  • Under the EC2 section, choose Instances, right-click an instance you wish to migrate and choose  Image --> Create Image


Here is an AWS CLI script:

@echo off
set /p id=Instance Id:
set /p name=AMI name:
"C:\Program Files\Amazon\AWSCLI\aws.exe" ec2 create-image --instance-id %id% --name %name%

Now you have created an Amazon Machine Image — an image of the whole instance with all operating system and software configurations. Now it’s time to launch.

Step 2: Launch created AMI in the desired Availability Zone / VPC / AWS Region

  • If you want to move your instance to a different region, then under the EC2 section choose AMIs, right-click your AMI and choose Copy AMI


  • Select a destination region and a new name for your AMI. Switch to your destination region and go to the next section.


Here is an AWS CLI script:

@echo off
set /p id=AMI id:
set /p region=Source region:
"C:\Program Files\Amazon\AWSCLI\aws.exe" ec2 copy-image --source-region us-east-1 --source-image-id %id% --name "Migrated"

Note: Before you run the script, run "C:\Program Files\Amazon\AWSCLI\aws.exe" and specify your destination region as a default.

  • If you need to move an instance to a different Availability Zone or VPC, choose AMIs under the EC2 section, right-click your AMI and choose Launch.


  • Choose an Instance type at the first step. Then choose desired VPC and desired subnet under the Configure Instance Details section. Also you will be asked to specify other settings such as Storage, Tags and Security groups.


Now you know how to successfully migrate your production Amazon EC2 instance to another Availability Zone, VPC or AWS Region by using native AWS tools. Notice that you don't have to stop it to perform a migration therefore not lose more time and money than needed.