Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'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
like image 992
MadzQuestioning Avatar asked Nov 24 '17 08:11

MadzQuestioning


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(...)
like image 152
Grzegorz Oledzki Avatar answered Oct 19 '22 02:10

Grzegorz Oledzki