Skip to content

Instantly share code, notes, and snippets.

@yuta-imai
Last active January 2, 2016 16:49
Show Gist options
  • Save yuta-imai/8332910 to your computer and use it in GitHub Desktop.
Save yuta-imai/8332910 to your computer and use it in GitHub Desktop.
The script to measure total size of objects in S3 bucket.
#!/usr/bin/env python
import boto
import sys
bucket_name = sys.argv[1]
s3 = boto.connect_s3()
bucket = s3.get_bucket(bucket_name)
iterator = bucket.list()
size = 0
for item in iterator:
size += item.size
print size
@yuta-imai
Copy link
Author

Setup

Configure your ENVIRONMENT VARIABLE

  • AWS_ACCESS_KEY_ID - Your AWS Access Key ID
  • AWS_SECRET_ACCESS_KEY - Your AWS Secret Access Key

Usage

$ python s3measurer.py BUCKET_NAME

Dependency

boto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment