I was wondering if someone can help me with this. I am trying to get a list of files in an s3 bucket by using boto3 without authenticating. I can accomplish this using aws s3 ls s3://mysite.com/ --no-sign-request --region us-east-2, but I am trying to do this in a pythonic manner using boto3.
Currently, when I try using boto.session.Session(), it is asking for credentials.
Thanks
I think a Session always requires credentials. You should be able to disable signing and use boto3.resource('s3') to access the bucket instead.
According to this answer:
from botocore.handlers import disable_signing
resource = boto3.resource('s3')
resource.meta.client.meta.events.register('choose-signer.s3.*', disable_signing)
And then it should be a case of:
bucket = resource.Bucket('mysite.com')
for item in bucket.objects.all():
print(item.key)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With