When pushing images to Amazon ECR, if the tag already exists within the repo the old image remains within the registry but goes in an untagged state.
So if i docker
I actually forged a one line solution using aws cli
aws ecr describe-repositories --output text | awk '{print $5}' | while read line; do aws ecr list-images --repository-name $line --filter tagStatus=UNTAGGED --query 'imageIds[*]' --output text | while read imageId; do aws ecr batch-delete-image --repository-name $line --image-ids imageDigest=$imageId; done; done
What it's doing is:
tagStatus=UNTAGGEDbatch-delete-image