If you have intentionally/accidentally deleted your aws instance, don’t panic. All hope is not lost yet. I will be writing about how to retrieve your terminated instance and get it to work again.
The essential part required to retrieve a terminated instance is your instance’s image snapshot. If you are lucky to have one, then your files can be retrieved to the date the snapshot was created. However, If you are unfortunate not to find any snapshot related to your instance image, then you should consider setting up a new instance.
As a system engineer, you should always have a regular backup of your files in case of situations like this.
To restore your EC2 instance on aws, I will be sharing a few steps and links to Amazon’s resources to help you achieve the process.
Login to the aws console and from the side menu, click Snapshots. I will assume that you don’t have an existing snapshot so we will create a new EBS snapshot.
Select the image you want to create a snapshot for from the dropdown. Then, wait for few minutes for the snapshot to be created. Once the snapshot’s is 100% (available) and that the status is completed. You can then proceed to create a new Image from the snapshot.
Select the snapshot you just created, right click or select from the actions button at the top of the list.
You can create a new volume or an image with the snapshot.
If you decide to use the volume as part of another instance or you simply want to replace an existing instance’s volume with the information of your terminated instance. You can create a new volume.
You can modify the size of the volume, add tags and click on the create volume button below.
However, if you wish to create an entire EBS image from the snapshot, simply click on the create image option from the drop-down menu above.
Enter the name of the image, the architecture(32 or 64bit) of your current image, root device name, virtualization type. You can uncheck the Delete on termination to avoid losing your files after you terminate your instance intentionally or accidentally.
Ensure to select the right virtualization type so that your system can perform without failures when you create another instance with the image.
In the navigation pane, choose AMIs
Select the image you created in the above step.
Click on launch and perform the other config, security groups, private key, etc…
Your EC2 instance should be ready in few minutes.
Take note that the state of your retrieved instance might be back to the date the snapshot was created. Hence, some files are lost. It’s better than losing all files and server configuration.
I hope I have been able to help you retrieve your terminated instance.