How do I get a list of my most expensive AWS buckets?

Tony mod
edited March 2022 in Security Operations
Is there a query for the Top 10 AWS S3 Buckets by Size and Cost?

Best Answer

  • jasmine_hex
    jasmine_hex admin
    Answer ✓
    find aws_s3_bucket with bucketSizeBytes!=undefined as bucket 
    return, bucket.tag.AccountName, 
        bucket.numberOfObjects, bucket.bucketSizeBytes, 
        bucket.bucketSizeBytes / 1000000000 * 0.023 as monthlyCost,
        bucket.lifecycleEnabled, bucket.retentionPeriod, bucket.webLink
    order by bucket.bucketSizeBytes DESC limit 10


  • Nice!  Is there a way to also identify the storage class(es) within those buckets?
  • crystralRamirez
    crystralRamirez ✭✭✭✭✭
    edited January 2022
    We can currently check to see if the S3 lifecycle has been enabled with the following query: 

    FIND aws_s3_bucket with lifecycleEnabled = true

    However, further integration work needs to be completed in order for us to see the lifecycle transitions. I just put in a feature request for this.  

This Month's Leaders