ECR Image Cleanup Tool
Project description
ECR Image Cleanup Tool
Table of Contents
Overview
The ECR Image Cleanup Tool addresses limitations in Amazon ECR's built-in lifecycle policies, particularly for multi-architecture images. It helps prevent repositories from hitting the 10,000 image hard limit imposed by ECR by providing more flexible and architecture-aware cleanup options.
Features
- Supports multi-architecture image cleanup
- Allows fine-grained control over image retention
- Can keep a specified number of recent images for each tag
- Manages untagged images separately
- Provides a dry-run option to preview actions before execution
GitHub-based version publishing
The simplest way to publish a new version (if you have committer rights) is to tag a commit and push it to the repo:
At a certain commit, ideally after merging a PR to main
git tag v0.1.x
git push origin v0.1.x
Manual
These steps can also be performed locally. For these commands to work, you will need to export two environment variables:
export TESTPYPI_PASSWORD=... # token for https://test.pypi.org/legacy/
export PYPI_PASSWORD=... # token for https://upload.pypi.org/legacy/
First, publish to the test repo and inspect the package:
task publish-test
If correct, distribute the wheel to the PyPI index:
Verify the distributed code
task publish-verify
Building a Docker image
Build an image with:
IMPORTANT: This project uses taskfile.dev, which you will need to install for running the following commands:
task docker-build
and run it with
task docker-run
# or
task docker-run ARGS="--repositories my-repo:tag-prefix=2,untagged=10 --region us-east-2 --dry-run"
Installation
pip install ecr-cleaner
Usage
Support following CLI argument
usage: ecr_cleaner [-h] [--config-file CONFIG_FILE] [--repositories REPOSITORIES [REPOSITORIES ...]] [--region REGION] [--batch-size BATCH_SIZE] [--dry-run] [--debug]
ECR Cleaner CLI
options:
-h, --help show this help message and exit
--config-file CONFIG_FILE
Path to configuration file in YAML format. See example in README.md
--repositories REPOSITORIES [REPOSITORIES ...]
List of repository names and policies(keep-most-recent). (e.g. my-repo:latest=3,tag-prefix=2,untagged=10)
--region REGION ECR region
--batch-size BATCH_SIZE
Max number of images that can be deleted in one call
--dry-run Check result without deleting images
--debug Enable debug logging
Clean-up will keep most recent number of images based on inputs and it will delete remaining matching tagPrefix
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ecr_cleaner-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31d45a37d89d2083c694c2ce205d3ab5dea79a3980a366d508738057e240dc2d |
|
MD5 | 66cf34ed679c03c765808835dda81625 |
|
BLAKE2b-256 | c072dfa115d0712bd5275f9f46e8fefdbb39e4518942d532e92eb7d06c5a01a8 |