aws s3 ls: List S3 Buckets and Objects in CI
List buckets, prefixes, and objects, with sizes and counts.
aws s3 ls lists buckets when given no path, or objects and prefixes when given an s3:// URI. In CI it is used to confirm an artifact landed, count objects, or verify a deploy prefix before invalidating a CDN.
Common flags
--recursive- list all objects beneath a prefix--human-readable- print sizes as KB/MB/GB--summarize- print total object count and size--page-size- control API page size for large buckets
Example in CI
Confirm artifacts exist under a release prefix.
shell
aws s3 ls s3://${ARTIFACT_BUCKET}/releases/${VERSION}/ --recursive --human-readable --summarizeCommon errors in CI
- An error occurred (AccessDenied) - role lacks s3:ListBucket on the bucket
- Unable to locate credentials - configure OIDC role auth
- The specified bucket does not exist - wrong name or region
Key takeaways
- aws s3 ls lists buckets with no path, or objects with an s3:// URI.
- Use --recursive --summarize to count and size a prefix in CI.
- Listing requires s3:ListBucket, distinct from object-level permissions.
Related guides
aws s3 cp: Copy Files to S3 in CIaws s3 cp copies files and directories to and from S3. Learn the recursive, exclude, and ACL flags plus a CI…
aws s3 sync: Sync a Directory to S3 in CIaws s3 sync uploads only changed files to S3, making it ideal for static site deploys in CI. Learn the delete…
aws s3 rm: Delete Objects from S3 in CIaws s3 rm deletes objects from S3, optionally recursively. Learn the recursive, exclude, and dryrun flags, a…