title: How to get size of all files in an S3 bucket with versioning?
body: <p>I know this command can provide the size of all files in a bucket:</p>
  
  <pre><code>aws s3 ls mybucket --recursive --summarize --human-readable
  </code></pre>
  
  <p>But this does not account for <a href="http://docs.aws.amazon.com/AmazonS3/latest/dev/Versioning.html" rel="noreferrer">versioning</a>.</p>
  
  <p>If I run this command:</p>
  
  <pre><code>aws s3 ls s3://mybucket/myfile --human-readable
  </code></pre>
  
  <p>It will show something like "100 MiB" but it may have 10 versions of this file which will be more like "1 GiB" total.</p>
  
  <p>The closest I have is getting the sizes of every version of a given file:</p>
  
  <pre><code>aws s3api list-object-versions --bucket mybucket --prefix "myfile" --query 'Versions[?StorageClass=`STANDARD`].Size' &gt; /tmp/s3_myfile_version_sizes
  </code></pre>
  
  <p>Then take the sum of all version sizes. </p>
  
  <p>But I would have to rerun this command for every file in a bucket.</p>
  
  <p>Is there an easier way to do this?</p>