Updated: Jul 29, 2021
Persists EBS volume beyond the life of an EC2 instance, take snapshot & restore the EBS volume in a different AZ. Attach the restored EBS volume to a new EC2 instance in that AZ.
1. Learn to persist EBS Volume beyond the life of an EC2 instance.
2. Replicate your application instance and data in a different AZ.
Step 1: Create a Linux Instance as follows:
Click on Instances option in left navigation pane so as to be directed to following page. Click on Launch Instance button on top left.
After clicking on the launch instance you will be redirected to this page. Here search/select Amazon Linux 2 AMI.
Choose an Instance Type over here.
Select General purpose type t2.micro Instance Type.
Click on Next: Configure Instance Details at the bottom right of the screen.
Here you will Configure Instance Details.
In the Subnet field select on the drop down list and select any one of the Subnets. It is ap-south-1a in our case.
Note This subnet for reference afterwards.
In the Auto-assign Public IP field select on the drop down list and select Enable option.
Click Next: Add Storage at bottom right of screen.
Step 2: In the step for Add Storage, click on the Add New Volume. Let everything be default. Mention the required size of volume in GB. 50 GB in our case.
Click on Next: Add Tags button in the down right corner.
Click on the Next: Configure Security Group at the bottom right of the screen.
Configure Security Group
Create a new security group and name it as LinuxSG
In the description enter the following text: Security Groups for Linux Servers
Keep the default SSH rule.
Warning: Rules with source of 0.0.0.0/0 allow all IP addresses to access your instance. We recommend setting security group rules to allow access from known IP addresses only.
While using this feature for production make sure the known IP address is entered.
Click on Review and Launch button on the bottom right corner
Review Instance Launch
Here are all the details regarding your instance. Read them once and check if all the configurations are correct
Click on the Launch button at the bottom right corner. This will launch your instance.
After you click the Launch button here you will be asked to select/create KEY-PAIR. Choose an existing key pair option from the drop down.
Acknowledge the key pair and launch the instance.
Click View Instance button at bottom right of the screen to see your launched instance.
Check if the instance is running.
Step 3: In the left panel of the AWS console go into Volumes under Elastic Block Store. Here you will see our 2 volumes created (One which was added by default with the instance and the other we added extra)
Name these two volumes as ROOT and DATA below the name category by clicking the pencil icon in the name column.
Step 4: Select the DATA volume. Go to Actions and click on Create Snapshot option.
Give details of the snapshot in the Create Snapshot pop-up window and click on Create Snapshot.
Step 5: Go to the Snapshots option on the left panel and check that the snapshot has been created.
Step 6: Create a new Linux Instance in different availability zone by choosing a different Subnet at Configure Instance Details step. Follow the Step 1 and Step 2.
Do not create an additional volume. Just keep the default Root Volume.
Note this Subnet. For our understanding we take the example as ap-south-1b
Step 7: Go to Snapshots under Elastic Block Store. Now click on Actions and select Create Volume.
We choose the same subnet in which this new Instance is created.
Click on Create Volume.
Step 8: In the same Volume Tab, we observe that the DATA2 volume is in available state and the root volume of new server is in in-use state.
Step 9: Go to Volumes. Select the DATA volume. Go to Action -> Attach Volume.
In the pop up window select your newly created instance in the Instance text field. Click on Attach button.
Thus the volume restored in a new availaibility zone through snapshot is attached to an instance in that AZ successfully.
Note: If you no longer need this instance and the volume make sure to terminate the instance and delete the volume as well as snapshots.
Was this document helpful? How can we make this document better. Please provide your insights. You can download PDF version for reference.
Download PDF • 1.04MB