Skip to content

Instantly share code, notes, and snippets.

@dkleissa
Created February 9, 2022 03:14
Show Gist options
  • Save dkleissa/d51a38cd2340a9e1e5ceca56e1e372ef to your computer and use it in GitHub Desktop.
Save dkleissa/d51a38cd2340a9e1e5ceca56e1e372ef to your computer and use it in GitHub Desktop.
A quick script to delete all repositories in AWS ECR
import boto3
client = boto3.client('ecr')
response = client.describe_repositories(maxResults=50)
next_token = response.get('nextToken')
while len(response['repositories']) > 0:
for r in response['repositories']:
print(f"Deleting {r['repositoryName']}")
response = client.delete_repository(
repositoryName=r['repositoryName'],
force=True
)
response = client.describe_repositories(maxResults=50, nextToken=next_token)
next_token = response.get('nextToken')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment