'S3' Object Has No Attribute 'Bucket'

'S3' Object Has No Attribute 'Bucket'

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
2

1 Answer

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(...)
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.