python

Check S3 Bucket

import os
import boto3
from botocore.exceptions import ClientError

client = boto3.client(
    's3',
    # Hard coded strings as credentials, not recommended.
    aws_access_key_id='',
    aws_secret_access_key=''
)
s3 = boto3.resource(
    's3',
    # Hard coded strings as credentials, not recommended.
    aws_access_key_id='',
    aws_secret_access_key=''
)
        
# print(bucket_subfolder)
bucket = 'bucket-name'

for my_bucket_object in s3.Bucket(bucket).objects.all():
    print(my_bucket_object)

This is to help see if you have access to a particular bucket on S3

Was this helpful?