How to Change Availability Zone of EC2 Instance (2 Methods)

AWS does not provide a direct option to move an existing instance to a new Availability Zone. However, there’s a workaround if you want to change the Availability Zone of an EC2 instance.

The process includes creating a new AMI from your EC2 instance and manually migrating it. After that, you need to launch a new instance in the new Availability Zone using that AMI and reassign existing Elastic IP addresses. Let’s break this process into small steps to make things easier to grasp.

How to Change Availability Zone of EC2 Instance

How Do I Change My Availability Zone?

As mentioned earlier, changing the Availability Zone of EC2 instances is a multi-step process. You can accomplish it either by using the AWS Systems Manager automation or manually launching a new instance. Here are the two methods in detail.

Change Availability Zone via AWS Automation Runbook

It is possible to create a new image and launch a new instance through the automation process of AWSSupport-CopyEC2Instance. Follow the steps below to run the automation successfully.

1. Copy the InstanceID of the EC2 instance for which you wish to change the Availability Zone.

2. Open AWSSupport-CopyEC2Instance runbook while ensuring that you are in the Region of the target EC2 instance.

3. Select Simple Execution when prompted to choose the Execute automation document.

4. Paste the InstanceId you copied and provide the new Availability Zone for the Input Parameters.

5. Fill in the optional fields as per your requirements and click on Execute.

You can see the automation progress by going to the Systems Manager console and reviewing the executed steps after selecting the running automation from the Automation page.

Manually Copy the Old Instance and Launch a New One

You can manually migrate an EC2 instance to a new Availability Zone using the Amazon EC2 console. Here’s how.

1. Open the Amazon EC2 console and click on Instances. Choose your desired instance and select Actions > Instance State > Stop.

Amazon EC2 console and click on Instances
select Actions  Instance State  Stop

2. Click Actions, select Image, and choose Create Image. Provide the image name and description of your new Amazon Machine Image (AMI). Click on Create Image to finish the process.

Click Actions, select Image, and choose Create Image
new Amazon Machine Image

3. Click View pending image [example ID] from the notification that pops up. After some time, the Status should become available.

Click View pending image

4. Choose the AMI you just created and select Launch. 

Choose the AMI you just created and select Launch

Use the same instance type for the old and the new instances. 

old and the new instances

Click Next: Configure Instance Details. Use the Availability Zone where you want to move the instance to.

Configure Instance Details

5. Choose the Add Storage option and keep the default selections. 

Add Storage option

Under the Add Tags section, enter the Name and Key of your instance.

Add Tags section

6. Go to Next: Configure Security Group and choose the security group associated with the target EC2 instance.

target EC2 instance

7. Click Review and Launch > Launch. Input your key pair and check the agreement. After that, select Launch Instances.

Click Review and Launch

8. Reassign the Elastic IP address by disassociating it from the source instance and associating it with the new one.

Frequently Asked Questions and Answers (FAQs)

What Availability Zone is my EC2 instance?

You can check the Availability Zone of your EC2 instance by opening the Amazon EC2 console. Go to the Regions selector, choose the region, and select EC2 Dashboard to view the Availability Zone information.

Can an EC2 instance be in multiple Availability Zones?

No, an Amazon Elastic Compute Cloud (EC2) instance cannot simultaneously be in multiple Availability Zones. However, you can create several EC2 instances and distribute them across different Availability Zones to achieve high availability and fault tolerance.

Is the subnet specific to the Availability Zone?

Every subnet is specific to one Availability Zone and cannot share zones. But you may launch your resources in separate Availability Zones if you want.

Conclusion

You can skip stopping your EC2 instance before copying and launching a new instance. Doing so is helpful when you prefer not to reboot your instance. Changing the Availability Zone for that particular EC2 instance will still be achievable using one of the above methods.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *