Frequently Asked Questions

Managing AMIs and Snapshots

What is the process for deleting unused EBS-based AMIs and their associated snapshots in AWS?

To delete unused EBS-based AMIs and their associated snapshots in AWS, first deregister the AMI using the AWS EC2 console or CLI. After deregistration, manually delete the associated snapshots, as AWS does not remove them automatically. You can use the AWS CLI commands aws ec2 deregister-image --image-id <ami-id> and aws ec2 delete-snapshot --snapshot-id <snapshot-id>. Alternatively, you can use provided PowerShell or Linux scripts to automate the process. Note: Always verify that no EC2 instances or auto-scaling groups depend on the AMI before deregistering it. Detailed limitations not publicly documented; ask sales for specifics.

Are there scripts available to automate the deletion of AMIs and their snapshots?

Yes, scripts are available for both PowerShell (Windows) and Linux environments to automate the deregistration of AMIs and deletion of associated snapshots. These scripts require you to provide the AMI ID and, for Linux, the AWS region. It is recommended to test these scripts in a non-production environment first and use IAM roles for security. Note: These scripts are provided as-is without warranty; always review and test before use in production. Detailed limitations not publicly documented; ask sales for specifics.

What best practices should I follow when managing AMIs and snapshots?

Best practices include tagging AMIs and snapshots with relevant metadata for lifecycle tracking, using AWS Resource Groups to find orphaned snapshots, creating backup plans with deletion schedules, checking dependencies before deregistering AMIs, and testing deletion scripts in non-production environments. Note: Not all best practices may apply to every environment; review your organization's policies before implementation.

Features & Capabilities

How does N2W help automate snapshot management and backup deletion?

N2W provides automated snapshot services and enterprise-class backup and disaster recovery for AWS EC2 environments. You can configure policies and schedules for automated snapshots and set policies to remove old snapshots, reducing manual effort and storage costs. Features include flexible backup policies, consistent database backup, cross-region recovery, and application-consistent backups. Note: N2W's automation is designed for AWS and Azure environments; support for other clouds is not documented.

What integrations and automation options does N2W offer?

N2W offers a RESTful API for custom integrations and automation, CLI access for advanced management, and integrations with third-party monitoring tools like Datadog, Splunk, and Bocada. These options enable automation of tasks such as user onboarding, backup management, and compliance tracking. API documentation is available for download. Note: Integration with platforms outside AWS and Azure is not documented.

What are the key features of N2W's backup and disaster recovery solution?

Key features include automated backup and recovery for AWS and Azure, near-instant recovery, immutable backups, cost optimization through intelligent storage tiering, compliance reporting, multi-cloud management, granular restore, and support for petabyte-scale data. Note: Some advanced features may require specific licensing or configuration; consult documentation for details.

Security & Compliance

What security and compliance certifications does N2W have?

N2W is independently certified for ISO/IEC 27001:2022 and is SOC compliant by inheritance through AWS and Azure. It also supports compliance with HIPAA, GDPR, FedRAMP, ITAR, and CJIS. Customers can request a copy of the ISO certificate by contacting customer.success@n2ws.com. Note: For the most current certifications, visit the N2W Trust Center.

How does N2W ensure data security and regulatory compliance?

N2W uses immutable, air-gapped backups, end-to-end encryption (TLS/HTTPS), multi-factor authentication, and audit-ready compliance reporting. The platform runs inside your AWS or Azure environment, ensuring data sovereignty and leveraging cloud-native security features. Note: Security features depend on correct configuration and cloud provider settings; review documentation for implementation guidance.

Use Cases & Benefits

Who can benefit from using N2W's backup and automation solutions?

N2W is designed for cloud directors, IT managers, managed service providers (MSPs), enterprises, public sector entities, healthcare, finance, retail, education, and nonprofits. It is especially beneficial for organizations managing large-scale AWS or Azure environments with strict compliance and data protection needs. Note: Organizations using other cloud providers may need to evaluate compatibility.

What business impact can customers expect from using N2W?

Customers can achieve up to 92% savings on long-term backup costs, reduce compute costs by up to 50%, minimize downtime with near-instant recovery, and simplify compliance with automated reporting. These benefits are documented in case studies from organizations like Skechers, St. John's University, and Deutsche Bahn. Note: Actual results may vary based on environment and configuration.

What pain points does N2W address for organizations managing AWS and Azure backups?

N2W addresses high disaster recovery costs, downtime and data loss, ransomware threats, manual backup processes, compliance challenges, complexity in multi-cloud environments, scalability for large data volumes, and long-term backup costs. Note: Some pain points may require additional configuration or integration; consult documentation for details.

Competition & Comparison

How does N2W compare to AWS Backup for managing backups and snapshots?

N2W offers immutable, air-gapped backups, cross-cloud recovery (AWS and Azure), granular file/folder-level restore, custom disaster recovery retention, and multi-tenancy support—features not available in AWS Backup. AWS Backup is limited to AWS environments, requires Lambda scripting for automation, and only provides preconfigured compliance templates. N2W also provides cost optimization through intelligent storage tiering and customizable compliance reporting. Note: AWS Backup may be preferable for organizations with simple, AWS-only environments and minimal automation needs.

Technical Requirements & Documentation

What technical documentation is available for N2W users?

N2W provides comprehensive user guides, release notes, RESTful API documentation, upgrade guides, and IAM permission files. These resources cover deployment, configuration, integration, and best practices. Documentation is available online and as downloadable PDFs. Note: Some documentation may require registration or support access.

How easy is it to implement N2W and get started?

Implementations can be completed in as little as two weeks, supported by dedicated Customer Success Managers, onboarding calls, and detailed documentation. N2W can be deployed as an Amazon Machine Image (AMI) or via CloudFormation templates. A 30-day free trial is available without a credit card. Note: Implementation time may vary based on environment complexity and resource availability.

Customer Proof & Success Stories

What feedback have customers given about N2W's ease of use?

Customers have praised N2W for its simplicity and user-friendly features. For example, Shane H., a verified customer, stated, "It's very simple to use and we are an MSP for multiple companies. Support is great and quick to respond." Julian Ware from the City of Oakland noted, "You’re just clicking and going. And, to me, that’s what the modern world of backup is." Note: Individual experiences may vary; see case studies for more details.

Can you share specific case studies or success stories of N2W customers?

Yes, organizations like Skechers, St. John's University, Deutsche Bahn, City of Oakland, Bahrain Ministry, and Gett have documented success with N2W, achieving cost savings, improved data protection, and business continuity. For example, Skechers standardized backup and recovery across a multi-cloud estate, and Gett saved 50% on cloud costs. See the N2W case studies page for details. Note: Results are specific to each organization and use case.

How-to Delete Unused EBS-Based AMIs and Corresponding Snapshots

Find out how to deregister AMIs and delete their snapshots. You can also copy the automated script that performs these actions.
Share post:

AWS AMIs refer to  pre-configured bundled software that has the necessary information to launch an EC2 instance. We can say that AMI refers to a root device for the instance; when an EC2 instance is launched from that AMI it will have all the OS, software as well as the applications which were bundled when that AMI was created.

If you create an AMI from an existing instance, once the AMI is created, AWS creates a snapshot of the root storage as well as all the EBS volumes that are attached to the instance. When you deregister the AMI, it is simply deleted. However, all the snapshots that were attached to the AMI remain and need to be deleted manually. The diagram  below illustrates this concept. If you do not manually delete snapshots after deregistering an AMI, they will continue to incur costs.

This article delves into how to deregister AMIs as well as delete snapshots. In addition, we provide you with an automated script that deletes all snapshots that are associated with a respective AMI while deregistering the AMI.

Part 1:

Deregister AMIs and delete snapshots using the Amazon Management Console & CLI To deregister an AMI, follow the steps below:

Go to the AWS EC2 console and AMI section. Select the desired AMI. Next, select the ‘Deregister’ option in the ‘Actions’ tab.

Delete unutilized AMI tutorial screenshot 1

Select the ‘Continue’ option to deregister. The AMI is now deregistered.

Delete unutilized AMI tutorial screenshot 2

You can perform the same steps using the AWS CLI, as shown below: (Note: It is assumed that AWS CLI has already been installed on the local machine.)

aws ec2 deregister-image --image-id <ami-id> 
Delete unutilized AMI tutorial screenshot 3

As mentioned above, the snapshots associated with the deregistered AMI are not automatically deleted, requiring you to delete them manually. This process is outlined below:

You can find the snapshots that are associated with the AMI using the AMI ID in the ‘Search’ option, as shown below:

Delete unutilized AMI tutorial screenshot 4

To delete the snapshot, select the snapshot and click on the ‘Delete’ option from the ‘Actions’ tab.

Delete unutilized AMI tutorial screenshot 5

You can perform the same steps using the AWS CLI, as shown below:

aws ec2 delete-snapshot --snapshot-id <snapshot-id>
Delete unutilized AMI tutorial screenshot 6

Part 2:

Delete the AMI and snapshots simultaneously using Powershell and a Linux script At times, it can be tedious to delete an AMI and then locate all of its associated snapshots in order to delete them, as well. Taking that into consideration, a script has been created that can delete both an AMI and its associated snapshots, simultaneously. All you need to do is enter the AMI ID into the script.

Two scripts have been created: one by PowerShell Script for Windows machines and the other by and for Linux. It is assumed that the AWS CLI was installed on both machines/instances and that the access credentials were set for the AWS account. If you run these scripts from an EC2 instance, it is recommended to use the AWS IAM Role for better security.

PowerShell Script:

$amiName = '<The users needs to mention their AMI ID>' $myImage = Get-EC2Image $amiName $count = $myImage[0].BlockDeviceMapping.Count
$mySnaps = @()
for ($i=0; $i -lt $count; $i++)
{
$snapId = $myImage[0].BlockDeviceMapping[$i].Ebs | foreach {$_.SnapshotId}
$mySnaps += $snapId
}
Write-Host "Unregistering" $amiName
Unregister-EC2Image $amiName
foreach ($item in $mySnaps)
{
Write-Host 'Removing' $item
Remove-EC2Snapshot $item
}
how to delete unutilized EBS screenshot 7

Linux Script:

#!bin/sh
# chkconfig: 2345 96 14
us_region_name=<Provide Region of AMI>'
ami_id='<Provide AMI ID>’'
temp_snapshot_id=''
my_array=( $(aws ec2 describe-images --image-ids $ami_id --region $us_region_name  --output text --query 'Images[*].BlockDeviceMappings[*].Ebs.SnapshotId') )
my_array_length=${#my_array[@]}
echo "Deregistering AMI: "$ami_id
aws ec2 deregister-image --image-id $ami_id --region $us_region_name
echo "Removing Snapshot"
for (( i=0; i<$my_array_length; i++ ))
do
temp_snapshot_id=${my_array[$i]}
echo "Deleting Snapshot: "$temp_snapshot_id
aws ec2 delete-snapshot --snapshot-id $temp_snapshot_id --region $us_region_name
done


n2ws

There are two types of AWS AMIs: EBS-backed and instance store-backed. In either case, when an instance is launched the root device is either the EBS volume or ephemeral storage, respectively. It is recommended to use snapshots at the application configuration level change for regular persistent storage backup. This could be useful for future instance launches if you want or need to create an AMI.

Tips from the Expert
Picture of Sebastian Straub
Sebastian Straub
Sebastian is the Principle Solutions Architect at N2WS with more than 20 years of IT experience. With his charismatic personality, sharp sense of humor, and wealth of expertise, Sebastian effortlessly navigates the complexities of AWS and Azure to break things down in an easy-to-understand way.

As explained above, when an AMI is deregistered, it does not delete its associated snapshots automatically, resulting in you having to delete them manually or by using the scripts outlined above.
N2WS offers an automated snapshot service and is an enterprise-class backup and disaster recovery solution for the EC2 compute cloud.

It is available as a service model that allows you to register multiple AWS accounts. You can configure policies and schedules to take automated snapshots for backup. You can configure policies to remove old snapshots, as well. N2WS provides automated and regular backup with the features below:

  • Flexible backup policies and schedules
  • Consistent database backup, such as SQL Server, Oracle, MySQL, MongoDB and more
  • Instance recovery, even with data located across AWS regions, within seconds
  • “Pull” and “Push” based alerts and notifications
  • Application consistent backup

Disclaimer:

This script was given as-is. You can use it for any purpose, redistribute it or modify it. We offer no warranty, expressed or implied, so we simply ask that you understand that it may not work.

You might also like