Skip to content

bonclay7/aws-amicleaner

Repository files navigation

aws-amicleaner

Cleanup your old unused ami and related snapshots

Travis CI codecov.io pypi

Maintenance note

This project is not under active maintenance but still active. Consider using the official AWS-supported Amazon Data Lifecycle Manager.

Description

This tool enables you to clean your custom Amazon Machine Images (AMI) and related EBS Snapshots.

You can either run in fetch and clean mode where the tool will retrieve all your private AMIs and EC2 instances, exclude AMIs being holded by your EC2 instances (it can be useful if you use autoscaling, and so on ...). It applies a filter based on their names or tags and a number of previous AMIs you want to keep. You can also check and delete EBS snapshots left orphaned by manual deletion of AMIs.

It can simply remove AMIs with a list of provided ids.

Prerequisites

This tool assumes your AWS credentials are in your environment, either with AWS credentials variables :

or with awscli :

Minimum AWS IAM permissions

To run the script properly, your aws user must have at least these permissions in iam:

Installation

amicleaner is available on pypi and can be installed on your system with pip

From pypi

From source

You can also clone or download from github the source and install with pip

Usage

Getting help

Fetch and clean

Print report of groups and amis to be cleaned

Keep previous number of AMIs

Regroup by name or tags

Exclude amis based on tag values

Skip confirmation, can be useful for automation

Activate orphan snapshots checking

Delete a list of AMIs

See this blog article for more information.