ECR lifecycle (Alpha)
Delete old images inside ECR repository using python and boto3
Table of Contents generated with DocToc
Requirements
- python3
- pip3
Credentials
Credentials will be taken from your AWS_PROFILE in your terminal when you execute this python script.
$ aws configure
$ export AWS_PROFILE="myprofile" # will be set in the terminal where you'll execute the python script
Installation
This tool is available in pypip package, so you can install it using your command line:
$ pip3 install ecr-lifecycle
Usage
Dry run
$ ecr-lifecycle -a 90 -r eu-west-1 -n repository/test/repo_name -l INFO
Delete images
$ ecr-lifecycle -a 90 -r eu-west-1 -n repository/test/repo_name -l INFO -d
Parameters
- -a: max age of the image(default: 30 days)
- -r: aws region
- -n: ECR repository name
- -l: level info (default: INFO)
- -d: (delete) execute the operation and delete images. Is destructive! Execute the cli first without '-d' in dry_run mode
Example
TO DO
You can store about 10mil images in a single ECR repository. Imagine, you have 2000mil images older than 90 days and you want to delete it. When you execute the program, the client of boto3 only returns a max of 1000 values, so you need to launch the program two times.
client = boto3.client('ecr', region_name=args.aws_region)
images = client.describe_images(
repositoryName=args.repository_name,
maxResults=1000, # here, limit of max results 1000
)
License
Metadata
Release files for ecr-lifecycle 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ecr-lifecycle-0.1.1.tar.gz | 8.8 kB | Without provenance | Details for ecr-lifecycle-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ecr_lifecycle-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for ecr_lifecycle-0.1.1-py3-none-any.whl |
Total release size: 18.7 kB
Release files / ecr-lifecycle-0.1.1.tar.gz
| Download URL | ecr-lifecycle-0.1.1.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dc7ec3fb9b1d0a93dc64260655e7c8201f8cf54adde37e9cad286ecb95730e36
|
|
BLAKE2b-256 checksum How to use checksums |
24be6f86aba5515d9134a5f07abacd48f2a7b6ca7f30aa2914df90d2377d9248
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / ecr_lifecycle-0.1.1-py3-none-any.whl
| Download URL | ecr_lifecycle-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb82cbef473c7ce9e9b0a2d83b492f3d58d9e335184f9e2ab57d6e20bfb84e73
|
|
BLAKE2b-256 checksum How to use checksums |
d98f8203fc38a49b8cf2c6d0586bd4d87a3abaf887bc28d3c01bbcd49e9e5ac1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for ecr-lifecycle 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.