karthikeayan
karthikeayan

Reputation: 5000

aws s3, why doesn't it list all the objects in the bucket?

I have an s3 bucket with around 80 objects which I can confirm from Cloudwatch metric. No prefixes/folders. All objects are in root path of the bucket.

When I do aws s3 ls bucket it is only showing current month's objects but not all and not previous month's objects. Even in AWS S3 console it is the same. I even tried aws s3 ls bucket --recursive

In the console, I see "viewing 1 of 24", but there are no buttons to navigate to see older objects.

Why is that? How can I see all objects in my bucket?

My s3 bucket storage class is standard.

Upvotes: 0

Views: 3735

Answers (2)

Vorsprung
Vorsprung

Reputation: 34297

You say that you believe that the number from the Cloudwatch metric, NumberOfObjects. Here is the definition of it from S3 docs

The total number of objects stored in a bucket for all storage classes except for the GLACIER storage class. This value is calculated by counting all objects in the bucket (both current and noncurrent objects) and the total number of parts for all incomplete multipart uploads to the bucket.

So the discrepancy between what you are viewing in the console and the metric is probably that you have versioning on and there are old ("noncurrent") versions that are being counted

There are instructions for seeing the old versions here

Upvotes: 1

James Dean
James Dean

Reputation: 4421

Cloudwatch metric for NumberOfObjects shows current and noncurrent objects and the total number of parts for all incomplete multipart uploads to the bucket.

You probably have Versioning enabled on the bucket and "s3 ls" only list current versions, this command doesn't return non current versions of an object. You can click on "Show all" in S3 console to see versioned objects or list-object-versions to get the total number of objects.

Reference:

Get all versions of an object in an AWS S3 bucket?

https://www.npmjs.com/package/s3-list-all-objects

Upvotes: 1

Related Questions