delete-ami-aws

How to delete an AMI in AWS using CLI and Console

An Amazon Machine Image (AMI) lets you launch EC2 instances with pre-configured settings. Over time, you may end up with several AMIs that are no longer needed and are just eating up your overall storage. Deleting them helps keep your environment clean and saves costs on storage. 

This guide shows how to delete AMIs using both the AWS Management Console and the AWS CLI.

How to delete an AMI in AWS

Let’s explore how you can delete an AMI in the AWS console.

Step 1: Sign in to the AWS Console

Go to the AWS website and sign in using your credentials.

Step 2: Open the EC2 Dashboard

Open the EC2 dashboard by typing EC2 in the search bar at the top and selecting EC2 under services.

Step 3: Go to AMIs

In the left menu, under Images, you will find AMIs. This will show you all the AMIs that are associated with your account.

Step 4: Deregister the AMI

Now, select the AMIs you want to delete by checking the boxes next to them. Then, click on Actions > Deregister AMI. 

You’ll need to confirm the action by clicking Deregister in the popup that comes up.

It’s important to note that this step removes the AMI from your account but does not delete the snapshot used to create the AMI.

Step 5: Delete the associated snapshot

In the left menu, go to Snapshots under Elastic Block Store and find the snapshot linked to the AMI that you deleted. You can match them using the Description or the ID.

Now, select the corresponding snapshots like you selected the AMIs and click on Actions > Delete snapshot.

On the other hand, if you want to delete an AMI in AWS using the CLI, you can do that too in 2 simple commands without having to open the AWS management console. 

Here’s the command to delete the AMI:

aws ec2 deregister-image --image-id ami-xxxxxxxxxxxxxxxxx

Here’s the command to delete the snapshot:

aws ec2 delete-snapshot --snapshot-id snap-xxxxxxxxxxxxxxxxx



Pump saves ~60% on CLOUD *for free*

FAQ

Get started with PUMP for free

No contracts, no credit card needed to sign up

Get started with PUMP for free

No contracts, no credit card needed to sign up

Get started with PUMP for free

No contracts, no credit card needed to sign up

1390 Market Street, San Francisco, CA 94102

Made with

in San Francisco, CA

© All rights reserved. Pump Billing, Inc.