Created
December 13, 2021 19:00
-
-
Save HarshadRanganathan/077e80f34f52d0a1a0d1358292226312 to your computer and use it in GitHub Desktop.
Bash script to delete ECR images in a filtered repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws ecr describe-repositories --output text | | |
awk '{print $6}' | | |
while read line; do | |
if [[ $line == *"api"* ]]; then | |
aws ecr list-images --repository-name $line --query 'imageIds[*]' --output text | |
fi | | |
while read imageDigest imageTag; do | |
aws ecr batch-delete-image --repository-name $line --image-ids imageDigest=$imageDigest; | |
done; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment