Skip to content

Deregistered an EC2 AMI deleting snapshots - AMI does not appear in Recycle Bin resources

0

Performed some tests before activating Recycle Bin

Test 1: I created Recycle bin retention rules for EBS snapshots and for AMIs. Rules have no exclusions. Retention set to 60 days. I deregistered an AMI that happens to have two snapshots, selecting snapshot deletion.

Under Recycle bin resources I can see the 2 snapshots. I cannot, though, see the AMI

Test 2: Tried a different test, de-registering an AMI without deleting the snapshots. Now i can see the AMI in the Recycle bin resources. Obviously I cannot see the snapshots since they were not deleted.

Documentation- I read the deregister docs . It briefly mentions the Recycle Bin but does not provide more details.

Questions:

  • Is the behavior in Test 1 expected? - If so, I would suggest documenting it in more detail.
  • Can an AMI in the recycle bin be recovered if its snapshots are no longer available?
  • If the answer to the first question is "yes" and the second "no". I guess the safe/recoverable procedure to deregister AMIs and delete their snapshots would be as outlined below. Would appreciate confirmation.
  1. Create rules for AMIs and EBS snapshots with the same retention period
  2. De-register AMIs without deleting snapshots. Note the snapshot IDs
  3. Delete snapshots
3 Answers
0
Accepted Answer

Based on the documentation, the behavior you observed in Test 1 is expected. When you deregister an EBS-backed AMI and choose to delete its associated snapshots at the same time, the AMI moves to the Recycle Bin only if it matches a retention rule. However, the snapshots are deleted as part of the deregistration process, which is why you see them separately in the Recycle Bin.

When you deregister an AMI without deleting snapshots (Test 2), the AMI itself goes to the Recycle Bin while the snapshots remain active, which is why you see the AMI but not the snapshots in Recycle Bin resources.

Regarding recovery: An AMI can only be restored from the Recycle Bin if it can be fully reconstructed. Since EBS-backed AMIs depend on their associated snapshots, if those snapshots are permanently deleted or no longer available, the AMI cannot be successfully restored to a functional state.

Your proposed safe procedure is sound:

  1. Create Recycle Bin retention rules for both AMIs and EBS snapshots with matching retention periods
  2. Deregister AMIs without deleting snapshots
  3. Separately delete the snapshots afterward

This approach ensures both the AMI and its snapshots are protected in the Recycle Bin and can be recovered independently within the retention period. This gives you the flexibility to restore either component if needed, and the AMI can be fully restored as long as its snapshots are still available in the Recycle Bin.

It's worth noting that deregistering an AMI does not affect instances already launched from it, and you'll continue to incur costs for both running instances and stored snapshots until you explicitly terminate or delete them.
Sources
Deregister an Amazon EC2 AMI - Amazon Elastic Compute Cloud
DeregisterImage - Amazon Elastic Compute Cloud
deregister - Boto3 1.42.50 documentation
deregister_image - Boto3 1.42.50 documentation

answered 2 months ago
EXPERT
reviewed 2 months ago
0

Hello.

If the EBS snapshot has been deleted and is not in the Recycle Bin, the AMI cannot be restored from the Recycle Bin.
I tried restoring using my AWS account, but an error occurred and I was unable to restore the AMI.
Therefore, as you understand, I believe it is safest to create the same retention rule for both AMIs and EBS snapshots.
As mentioned in the following documentation, a snapshot is required to use an AMI, so if there is no snapshot left in the Recycle Bin, I think the AMI will also become unusable.
https://docs.aws.amazon.com/ebs/latest/userguide/recycle-bin-working-with-amis.html#recycle-bin-restore-ami

You can't use an AMI in any way while it is in the Recycle Bin. To use the AMI, you must first restore it. When you restore an AMI from the Recycle Bin, the AMI is immediately available for use, and it is removed from the Recycle Bin. You can use a restored AMI in the same way that you use any other AMI in your account.

EXPERT
answered 2 months ago
0

Thank you for the prompt response and review.

I have double checked and will recommend to my customer using the outlined procedure.

Unless I am missing something, I think the documentation quoted by Riku, while useful, does not apply directly to my question (in my case the snapshots were in the recycle bin, the AMI wasn´t)

I would still recommend updating the docs

answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.