{"id":882,"date":"2016-03-16T18:01:58","date_gmt":"2016-03-16T18:01:58","guid":{"rendered":"http:\/\/shivdev.com\/blog\/?p=882"},"modified":"2016-03-16T18:01:58","modified_gmt":"2016-03-16T18:01:58","slug":"determine-size-of-an-s3-bucket-or-folder","status":"publish","type":"post","link":"http:\/\/shivdev.com\/blog\/2016\/03\/16\/determine-size-of-an-s3-bucket-or-folder\/","title":{"rendered":"Determine size of an S3 bucket or folder"},"content":{"rendered":"<p>Ensure that you have <a href=\"https:\/\/aws.amazon.com\/cli\/\">awscli<\/a> installed as well as your keys setup in <strong>~\/.aws\/credentials<\/strong> <\/p>\n<p>To determine the size of an S3 Bucket or a folder, you can summarize the output as follows.<\/p>\n<blockquote><p><strong>aws s3 ls &#8211;summarize &#8211;human-readable &#8211;recursive <em>s3:\/\/mybucket\/directory\/<\/em><\/strong><br \/>\n&#8230;<br \/>\n2015-03-05 19:57:33   71 Bytes directory\/sub1\/sub2\/file.gz<br \/>\n&#8230;<br \/>\nTotal Objects: 71<br \/>\n   Total Size: 81.9 MiB\n<\/p><\/blockquote>\n<p>To determine the size of an S3 Bucket, you can also use s3api list-objects as shown below.<\/p>\n<blockquote><p><strong>aws s3api list-objects &#8211;bucket <em>mybucket<\/em> &#8211;output json &#8211;query &#8220;[sum(Contents[].Size), length(Contents[])]&#8221;<\/strong><br \/>\n[<br \/>\n    351885203186,<br \/>\n    4668<br \/>\n]<\/p><\/blockquote>\n<p>For more info refer to <a href=\"http:\/\/serverfault.com\/questions\/84815\/how-can-i-get-the-size-of-an-amazon-s3-bucket\">ServerFault<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ensure that you have awscli installed as well as your keys setup in ~\/.aws\/credentials To determine the size of an S3 Bucket or a folder, you can summarize the output as follows. aws s3 ls &#8211;summarize &#8211;human-readable &#8211;recursive s3:\/\/mybucket\/directory\/ &#8230; 2015-03-05 19:57:33 71 Bytes directory\/sub1\/sub2\/file.gz &#8230; Total Objects: 71 Total Size: 81.9 MiB To determine [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[35],"tags":[],"_links":{"self":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/882"}],"collection":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/comments?post=882"}],"version-history":[{"count":1,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/882\/revisions"}],"predecessor-version":[{"id":883,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/882\/revisions\/883"}],"wp:attachment":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/media?parent=882"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/categories?post=882"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/tags?post=882"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}