aws/s3-ls

List S3 Buckets

List S3 buckets or objects in a bucket.

aws
s3
list

Command

aws s3 ls

Explanation

Lists all S3 buckets or, if a specific bucket is provided, lists the contents (objects) within that bucket.

Common Use Cases

  • Verifying bucket creation
  • Viewing bucket contents
  • Checking file uploads

Best Practices

  • Use IAM roles with least privilege for listing operations
  • Use pagination for large buckets with the `--page-size` flag

Common Mistakes to Avoid

  • Forgetting the trailing slash in the bucket path (`s3://bucket/`)
  • Listing without permissions (missing `s3:ListBucket` policy)

Troubleshooting

Problem: Access denied

Solution: Ensure your IAM user has `s3:ListAllMyBuckets` or `s3:ListBucket` permissions.

Problem: Empty list

Solution: Confirm the bucket name and region are correct.

Examples

List all S3 buckets

aws s3 ls

List objects within a specific bucket

aws s3 ls s3://my-bucket/