I looked at the AWS Console and I don't see a way to display or list the storage class in a bucket for directories. I can see how to change the storage class, but it doesn't display what it is currently set at. Is there a way to do this through the AWS Console? Can this be also be done through the AWS cli?
Asked
Active
Viewed 2,936 times
1 Answers
3
Use the list-objects
command to see the storage classes for objects in a specific bucket:
aws s3api list-objects --bucket <bucket name>
will give you an output similar to this for each object in the bucket:
{ "Key": "kenland-logs2019-12-24-11-20-28-5FC9DBFAA3DC7CB6", "LastModified": "2019-12-24T11:20:29.000Z", "ETag": "<Redacted>", "Size": 662, "StorageClass": "STANDARD", "Owner": { "DisplayName": "s3-log-service", "ID": "<Redacted>" } },
If you only want the Key and the Storage class you can tack this on to the end:
--query 'Contents[].{Key: Key, StorageClass: StorageClass}'
Reference

kenlukas
- 3,101
- 2
- 16
- 26
-
You can now do this by using S3 Inventory: https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-inventory.html – RHPT Nov 27 '21 at 18:02