1import boto3
2import pprint
3
4s3 = boto3.resource('s3')
5pp = pprint.PrettyPrinter(indent=2)
6
7SRV_ACC_ACCESS_KEY = "<Add Key Access ID here>"
8SRV_ACC_SECRET_KEY = "<Add Key Secret here>"
9SRV_BUCKET_NAME = "<Add bucket name here>"
10
11def get_gcs_objects(google_access_key_id, google_access_key_secret, gc_bucket_name):
12 """Gets GCS objects using boto3 SDK"""
13 client = boto3.client("s3", region_name="auto",
14 endpoint_url="https://storage.googleapis.com",
15 aws_access_key_id=google_access_key_id,
16 aws_secret_access_key=google_access_key_secret)
17
18 # Call GCS to list objects in gc_bucket_name
19 response = client.list_objects(Bucket=gc_bucket_name)
20 pp.pprint(response)
21
22get_gcs_objects(SRV_ACC_ACCESS_KEY, SRV_ACC_SECRET_KEY, SRV_BUCKET_NAME)