Wondering how to recover an accidentally deleted AMI on EC2? We can help you.
Here, at Bobcares, we assist our customers with several AWS queries as part of our AWS Support Services.
Today, let us see how to fix this error.
How to recover an accidentally deleted AMI on EC2?
You can create a new, identical AMI using one of the following:
- Amazon Elastic Block Store (Amazon EBS) snapshots that were created as backups.
- Amazon Elastic Compute Cloud (Amazon EC2) instances that were launched from the deleted AMI.
Restore the AMI from an EBS snapshot
When you delete or deregister an Amazon EBS-backed AMI, any snapshots created for the volume of the instance during the AMI creation process are retained.
If you accidentally delete the AMI, you can launch an identical AMI using one of the retained snapshots.
Today, let us see steps followed by our Support Techs to create an AMI from a snapshot using console
1.Firstly, open Amazon EC2 console at https://console.aws.amazon.com/ec2/.
2.In the navigation pane, under Elastic Block Store, choose Snapshots.
3.Then, choose the snapshot and choose Actions, Create Image.
4.In the Create Image from EBS Snapshot dialog box, complete the fields to create your AMI, then choose Create.
If you’re re-creating a parent instance, then choose the same options as the parent instance.
Architecture: Choose i386 for 32-bit or x86_64 for 64-bit.
Root device name: Enter the appropriate name for the root volume.
Virtualization type: Choose whether instances launched from this AMI use paravirtual (PV) or hardware virtual machine (HVM) virtualization.
Kernel ID and RAM disk ID: Choose the AKI and ARI from the lists. If you choose the default AKI or don’t choose an AKI, you must specify an AKI every time you launch an instance using this AMI.
In addition, your instance may fail the health checks if the default AKI is incompatible with the instance.
Block Device Mappings: Add volumes or expand the default size of the root volume for the AMI.
Restore the AMI from an EC2 instance
If you deleted the AMI and the snapshots are also deleted, then you can recover the AMI from any existing EC2 instances launched using the deleted AMI.
Please note unless you have selected the No reboot option on the instance, performing the following procedure reboots the instance.
- Firstly, open the Amazon EC2 console.
- Choose Instances, and then select the instance that you want to use to create the AMI.
- Select Actions, Image, Create Image.
Please follow below steps to create an AMI from an instance using the console:
1.Select an appropriate EBS-backed AMI to serve as a starting point for your new AMI, and configure it before launch.
2. Then, choose Launch to launch an instance of EBS-backed AMI that you’ve select. Accept default values as you step through the wizard.
3.While the instance is running, connect to it. You can perform any of following actions on your instance to customize it for your needs:
- Install software and applications
- Copy data
- Reduce start time by deleting temporary files, defragmenting your hard drive, and zeroing out free space
- Attach additional EBS volumes
4.Create snapshots of all the volumes attached to your instance.
5.In the navigation pane, choose Instances, select your instance, and then choose Actions, Image and templates, Create image.
6.On the Create image page, specify the following information, and then choose Create image.
- Image name – A unique name for the image.
- Image description – An optional description of the image, up to 255 characters.
- No reboot – This option is not select by default. Amazon EC2 shuts down the instance, takes snapshots of any attached volumes, creates and registers the AMI, and then reboots the instance.
Select No reboot to avoid having your instance shut down.
- Instance volumes – The fields in this section enable you to modify the root volume, and add additional Amazon EBS and instance store volumes.
- Tags – You can tag the AMI and the snapshots with same tags, or you can tag them with different tags.
7.To view the status of your AMI while it is being created, in the navigation pane, choose AMIs.
8.Launch an instance from your new AMI.
9.The new running instance contains all of the customization that you apply in previous steps.
[Need help with the troubleshooting? We’d be happy to assist]
In short, today we saw how our Support Techs recover an accidentally deleted AMI on EC2.