Created
September 15, 2016 11:39
-
-
Save seventhskye/81b2d21347c852d67ffbf39c001b67dd to your computer and use it in GitHub Desktop.
A script to loop through a list of bucket objects that would exceed the max-keys.
This file contains hidden or 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
#!/usr/bin/env python | |
import boto3 | |
client = boto3.client('s3') | |
bucket = 'you-s3-bucket' | |
prefix = 'a-prefix' | |
NextContinuationToken = True | |
while NextContinuationToken: | |
if NextContinuationToken == True: | |
response = client.list_objects_v2(Bucket=bucket,Prefix=prefix) | |
else: | |
response = client.list_objects_v2(Bucket=bucket,Prefix=prefix,ContinuationToken=NextContinuationToken) | |
NextContinuationToken = response['NextContinuationToken'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment