Created
August 24, 2020 15:16
-
-
Save genslein/5bb6d328707daa9a0ada8fde9d14b4f0 to your computer and use it in GitHub Desktop.
s3 bucket query and stats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
resource = boto3.resource( | |
's3', | |
aws_access_key_id = 'my_access_key', | |
aws_secret_access_key = 'my_secret_key', | |
endpoint_url = 'http://s3.target.endpoint.minio-compatible.com', | |
) | |
bucket = resource.Bucket('my_test_bucket') | |
bucket.create() | |
client = boto3.client( | |
's3', | |
aws_access_key_id = 'my_access_key', | |
aws_secret_access_key = 'my_secret_key', | |
endpoint_url = 'http://s3.target.endpoint.minio-compatible.com', | |
) | |
folder_name = "my_folder_name" # used for wal-g | |
client.put_object(Bucket='my_test_bucket', Key=(folder_name+'/')) | |
# Checks explicitly what's stored in S3 in bytes | |
total_size = 0 | |
bucket = resource.Bucket('my_test_bucket') | |
for object in bucket.objects.all(): | |
total_size += object.size | |
# print(object.size) | |
print(total_size) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment