Created
February 9, 2022 03:14
-
-
Save dkleissa/d51a38cd2340a9e1e5ceca56e1e372ef to your computer and use it in GitHub Desktop.
A quick script to delete all repositories in AWS ECR
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
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