1 Answer
- Newest
- Most votes
- Most comments
0
You can refer to the S3 storage metrics provided by CloudWatch, like BucketSizeBytes
and NumberOfObjects
,but these metrics might not offer the granularity you want, as they are for the entire bucket and don't distinguish between current and non-current versions.However, you can use a combination of S3, S3 Inventory, and possibly Athena to get the details of non current versions.
Here are the steps:
- Go to the S3 bucket, under the Management tab, set up an inventory which includes the
IsLatest
andSize
fields and export S3 Inventory to a location. - Once you have the inventory files in S3, you can set up an Athena table to query these files.
- Using Athena, you can then query for all the objects where
IsLatest
isfalse
(meaning they are non-current versions), sum up their sizes, and filter by the specific folder if needed.
- Using Athena, you can then query for all the objects where
Here is an example athena query:
SELECT SUM(size) as TotalNonCurrentVersionBytes FROM s3_inventory_table WHERE is_latest = 'false' AND key LIKE 'your-folder-name/%';
This would give you the total size of non-current version bytes for the specified folder.
answered 9 months ago
Relevant content
- asked 2 years ago
- Accepted Answerasked 10 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 2 years ago