How to list _all_ objects in Amazon S3 bucket?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
To list all objects in an S3 bucket, you need to handle pagination. Large buckets are not returned in one response, so the correct answer is not just “call list objects once,” but “keep following pages until there are no more results.”
Use the AWS CLI for a Quick Listing
For simple inspection from the command line:
That is convenient for humans, but applications usually need to use the SDK or API directly.
Use Pagination in Code
In Python with Boto3, the usual answer is a paginator.
This is the correct scalable pattern because it keeps requesting additional pages until the bucket listing is complete.
Understand What “All Objects” Really Means
S3 listings can also be filtered by prefix, so make sure you know whether you want:
- every key in the bucket
- every key under a prefix
- only current versions versus a version-aware listing
The API shape matters if the bucket is large or versioned.
Common Pitfalls
- Calling the listing API once and assuming the bucket contents were complete.
- Forgetting that empty pages may need a safe fallback when
Contentsis absent. - Confusing a prefix-scoped listing with a full-bucket listing.
- Using recursive CLI listing for automation when an SDK paginator would be more controllable.
- Assuming S3 “folders” are real directories instead of key prefixes.
Summary
- Large S3 bucket listings require pagination.
- The AWS CLI can list recursively for quick human use.
- SDK paginators are the normal answer for application code.
- Be clear about whether you want the whole bucket or only a prefix.
- In S3, object listing is fundamentally key-prefix traversal, not directory walking.
Related reading
- How to list all AWS S3 objects in a bucket using Java
- How to list available regions with Boto3 Python
- How to list kubernetes services in k9s?
- How to load a pickle file from S3 to use in AWS Lambda?
- How to load a graph with tensorflow.so and c_api.h in c language?
- How to log formatted message, object array, exception?
- How to load npm modules in AWS Lambda?
- How to log all Cognito User details in API Gateway Cloudwatch

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.