Amazon EC2 instances are hosted in multiple locations worldwide. These locations are known as Regions, Availability Zones, and Local Zones. Each Region is a separate geographic area that has multiple, isolated locations known as Availability Zones. In this article, we will show you how to move your Amazon EC2 instance to another availability zone within the same AWS region. This article consists of two parts. The first part is about moving an Amazon EC2 instance from availability zone us-east-2b to availability zone us-east-21. Both instances are running in the US East (Ohio) region. The second part is about associating Elastic IP address to the moved IAM image.
Part I: Move Amazon EC2 instance from us-east-2b to us-east-2a
In the first part, we will move Amazon EC2 instance from one to another availability zone.
- Login into AWS Management Console
- Click on Services and then click on EC2
- Click on Running instances
- Right click on the instance and then click on Instance state > Stop
- Right click on the instance and then click on Image > Create Image
- Under Create Image fill in the following settings and then click on Create image.
- Image name – type the name of the image
- Image description – type the description of the contents and purpose of the image.
- No reboot – When enabled, Amazon EC2 does not shut down the instance before creating the image. When this option is used, file system integrity on the created image cannot be guaranteed. In our case it is disabled.
- Instances Volumes – define the volume size and volume type. In case you want to create an additional volume click on Add New Volume. We will keep the default settings.
- Click on View pending image ami-xxxxxxxxxx under Create Image request received.
- The AMI image is successfully created as can be seen under Status: available.
- Right click on AMI image and then click on Launch
- Choose an Instance Type and then click on Next: Configure Instance Details. In our case, we will choose t2.micro (Variable ECUs, 1 vCPUs, 2.5 GHz, Intel Xeon Family, 1 GiB memory, EBS only)
- We will move an Amazon EC2 instance from us-east-2b to an us-east-2a availability zone. Please change it under Subnet. Also, we do recommend enabling termination protection which will protect instances from being accidentally terminated. Once you do that click on Review and Launch.
- Review instance settings and then click Launch.
- Select an existing key pair or create a new key pair. A key pair consists of a public key that AWS stores, and a private key file that you store. Together, they allow you to connect to your instance securely. If you click on Create a new key pair, you will need to define pair name and Download key Pair that will be used to decrypt Windows password. You have to download the private key file (*.pem file) before you can continue.
- Click Launch Instances.
- Your instances are now launching. Click on View launches.
- Please wait a few minutes until your instance is successfully initialized
Part II: Reassign Elastic IP to moved Amazon EC2 instance
In the second part, we will disassociate the Elastic IP from the image and associate it to a moved image.
- On the left side click on Elastic IPs under Network & Security
- Select the Elastic IP and then click on Actions > Disassociate Elastic IP address
- Under Dissociate Elastic IP address click on Disassociate. If you disassociate this Elastic IP address, you can reassociate it with a different resource. The Elastic IP address remains allocated to your account. Elastic IP addresses incur charges if they are not associated with a running instance or a network interface that is attached to a running instance.
- Select the Elastic IP and then click on Actions > Associate Elastic IP address
- Type Instance and Private IP address
- Select Allow this Elastic IP address to be reassociated and then click on Associate
- You have successfully assigned an Elastic IP address to Amazon EC2 instance. Click on Instances on the left side of the window and then verify if your instance that is moved to another availability zone is working fine.