I'm working to in a project and the goal is to pull report from amazon S3. Currently I'm trying to access to an S3 location to check my available bucket list.
Im working in python, I've set all my credentials in the prompt : aws configure.
In my python file when i'm try the code to list all my bucket :
import boto3
s3 = boto3.resource('s3')
for bucket in s3.buckets.all():
print (bucket.name)
I'm getting this error :
Traceback (most recent call last): File "C:\Users\bakpovo\testAmazon.py", line 3, in for bucket in s3.buckets.all(): File "C:\Users\bakpovo\AppData\Local\Programs\Python\Python38\lib\site-packages\boto3\resources\collection.py", line 83, in iter for page in self.pages(): File "C:\Users\bakpovo\AppData\Local\Programs\Python\Python38\lib\site-packages\boto3\resources\collection.py", line 161, in pages pages = [getattr(client, self._py_operation_name)(**params)] File "C:\Users\bakpovo\AppData\Local\Programs\Python\Python38\lib\site-packages\botocore\client.py", line 276, in _api_call return self._make_api_call(operation_name, kwargs) File "C:\Users\bakpovo\AppData\Local\Programs\Python\Python38\lib\site-packages\botocore\client.py", line 586, in _make_api_call raise error_class(parsed_response, operation_name) botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the ListBuckets operation: Access Denied
Does someone have any idea of what happened? Are my creadentials not good?
Thanks
aws s3
terminal/shell command? 2. After runningaws configure
do you have a valid shared credentials file~/.aws/credentials
? 3. Ref boto3.amazonaws.com/v1/documentation/api/latest/guide/… do you have anything that would prevent boto3 from using the shared credentials file (e.g. environment variables set)? – Tom Daltondefault
profile? If you have multiple s3 accounts/ profiles it can be useful to setup named profiles and then create a session:session = boto3.Session(profile_name=<NAME HERE>) s3 = session.resource("s3")
– Alexaws s3 ls s3
doesn't work with the same error then your credentials are not set up correctly. – Tom Dalton