'S3' object has no attribute 'Bucket'

Viewed 51237

I'm receiving this error 'S3' object has no attribute 'Bucket' any idea? below is my code

self.client = boto3.client(
        's3',
        aws_access_key_id= access_key,
        aws_secret_access_key= secret
    )
the_bucket = self.client.Bucket('my_bucket') # but I'm receiving an error here
1 Answers

There is more than one way to interact with Boto3.

The high-level one using resource() and classes like S3.Bucket. And the low-level one using boto3.client(...). You are kind of mixing these two.

If you look here it will clarify the difference. In short...

High-level example

s3 = boto3.resource('s3') 
the_bucket = s3.Bucket('my_bucket')

Low-level example

self.client = boto3.client(...)
self.client.create_bucket(...)
Related