Skip to content

Instantly share code, notes, and snippets.

@yogeek
Created July 2, 2020 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yogeek/79451eeb411af58cb953d410a0dab0c2 to your computer and use it in GitHub Desktop.
Save yogeek/79451eeb411af58cb953d410a0dab0c2 to your computer and use it in GitHub Desktop.
ECR
#!/bin/bash
REPOS=$(aws ecr describe-repositories --query 'repositories[].repositoryName' --output text)
for repo in $REPOS; do
TAGS=$(aws ecr list-images --repository-name $repo --query 'imageIds[].imageDigest' --output text)
for tag in $TAGS; do
echo "Deleting image: $tag"
aws ecr batch-delete-image --repository-name $repo --image-ids imageDigest=$tag
done
done
echo "Deleting repos..."
for repo in $REPOS; do
aws ecr delete-repository --repository-name $repo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment