All New

user:thomas gists created by user

title:mygist gists with given title

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

Login


All New Login

All gists matching topic ecr

Recently created
Least recently created
Recently updated
Least recently updated

botanikanet / ECR Cleanup

0 likes
0 forks
1 files
Last active 4 months ago
Script for cleanup ecr
aws ecr example
1 aws ecr get-login-password | docker login --username AWS --password-stdin $(aws ecr describe-registry --query registryId --output text).dkr.ecr.eu-west-1.amazonaws.com
2 for REPOSITORY in $(aws ecr describe-repositories | jq -r '.repositories[].repositoryName'); do echo "${REPOSITORY}"; aws ecr describe-images --repository-name ${REPOSITORY} | jq --arg pull_t $(date +%Y-%m-%dT00:00:00 -d '1 months ago') --arg push_t $(date +%Y-%m-%dT00:00:00 -d '3 months ago') '.imageDetails|sort_by(.imagePushedAt) [:-20] | .[] | select(.lastRecordedPullTime? | . <= $pull_t ) | select(.imagePushedAt | . <= $push_t ) | "imageDigest=\(.imageDigest)"' | tr '\n' ' ' | xargs -n 99 -r aws ecr batch-delete-image --no-cli-pager --repository-name ${REPOSITORY} --image-ids; done
Newer Older

Powered by Opengist ⋅ Load: 19ms⋅

English
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文