Skip to content

Instantly share code, notes, and snippets.

@moroz
Created December 16, 2022 23:18
Show Gist options
  • Save moroz/5c45c04afefcacea256f1e40fcdb8126 to your computer and use it in GitHub Desktop.
Save moroz/5c45c04afefcacea256f1e40fcdb8126 to your computer and use it in GitHub Desktop.
Empty an ECR repository
#!/bin/sh
# Implies that AWS_PROFILE and AWS_REGION are set
aws ecr list-images --repository-name $1 \
| jq -r '.imageIds[].imageTag' \
| xargs printf -- 'imageTag=%s\n' \
| xargs aws ecr batch-delete-image --repository-name $1 --image-ids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment