Deregistering Your AMI
You can deregister an AMI when you have finished using it. After you deregister an AMI, you can't use it to launch new instances.
When you deregister an AMI, it doesn't affect any instances that you've already launched from the AMI. You'll continue to incur usage costs for these instances. Therefore, if you are finished with these instances, you should terminate them.
The procedure that you'll use to clean up your AMI depends on whether it is backed by Amazon EBS or instance store. (Note that the only Windows AMIs that can be backed by instance store are those for Windows Server 2003.)
Cleaning Up Your Amazon EBS-Backed AMI
When you deregister an Amazon EBS-backed AMI, it doesn't affect the snapshot that was created for the root volume of the instance during the AMI creation process. You'll continue to incur storage costs for this snapshot. Therefore, if you are finished with the snapshot, you should delete it.
The following diagram illustrates the process for cleaning up your Amazon EBS-backed AMI.
To clean up your Amazon EBS-backed AMI
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
In the navigation pane, choose AMIs. Select the AMI, and take note of its ID — this can help you find the correct snapshot in the next step. Choose Actions, and then Deregister. When prompted for confirmation, choose Continue.
The AMI status is now
It may take a few minutes before the console changes the status from
unavailable, or removes the AMI from the list altogether. Choose Refresh to refresh the status.
In the navigation pane, choose Snapshots, and select the snapshot (look for the AMI ID in the Description column). Choose Actions, and then choose Delete Snapshot. When prompted for confirmation, choose Yes, Delete.
(Optional) If you are finished with an instance that you launched from the AMI, terminate it. In the navigation pane, choose Instances. Select the instance, choose Actions, then Instance State, and then Terminate. When prompted for confirmation, choose Yes, Terminate.
Cleaning Up Your Instance Store-Backed AMI
When you deregister an instance store-backed AMI, it doesn't affect the files that you uploaded to Amazon S3 when you created the AMI. You'll continue to incur usage costs for these files in Amazon S3. Therefore, if you are finished with these files, you should delete them.
The following diagram illustrates the process for cleaning up your instance store-backed AMI.
To clean up your instance store-backed AMI
Deregister the AMI using the deregister-image command as follows.Copy
aws ec2 deregister-image --image-id
The AMI status is now
Delete the bundle in Amazon S3 using the rm command. For example, this command recursively removes the files that start with
mybundle(assume this is the S3 key you used when you created the bundle, and assume you don't have other important objects in this bucket that use this key).Copy
aws s3 rm
s3://myawsbucket/myami--recursive --exclude "*" --include "mybundle.*"
(Optional) If you are finished with an instance that you launched from the AMI, you can terminate it using the terminate-instances command as follows.Copy
aws ec2 terminate-instances --instance-ids
(Optional) If you are finished with the Amazon S3 bucket that you uploaded the bundle to, you can delete the bucket. To delete an Amazon S3 bucket, open the Amazon S3 console, select the bucket, choose Actions, and then choose Delete.