Created
October 22, 2020 00:45
-
-
Save yeisoncruz16/d409c819b355a2c8fec49e1fe445c571 to your computer and use it in GitHub Desktop.
Simple bash script
This file contains 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
#!/bin/bash | |
ECR_REGION='us-east-1' | |
ECR_REPO='YOUR_REPO_GO_HERE' | |
IMAGES_TO_DELETE=$( aws ecr list-images --region $ECR_REGION --repository-name $ECR_REPO --filter "tagStatus=UNTAGGED" --query 'imageIds[*]' --output json ) | |
if [ "$IMAGES_TO_DELETE" == [] ] | |
then | |
echo "--> There are no UnTagged Images <--"; | |
else | |
aws ecr batch-delete-image --region $ECR_REGION --repository-name $ECR_REPO --image-ids "$IMAGES_TO_DELETE" || true | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment