Downloading the file from S3 through AWS cli works, but through python SDk I receive 403 forbidden error! I am using the same credentials.
from boto3.session import Session
ACCESS_KEY = '******'
SECRET_KEY = '******'
session = Session(aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY,
region_name='eu-west-1'
)
s3 = session.resource('s3')
bucket_name = "****"
s3.meta.client.download_file(bucket_name, 's3://folder/xyz.tar.xz', 'abc.tar.xz')
File "/Users/abh16/controldbagent/lib/python3.8/site-packages/s3transfer/futures.py", line 106, in result
return self._coordinator.result()
File "/Users/abh16/controldbagent/lib/python3.8/site-packages/s3transfer/futures.py", line 265, in result
raise self._exception
File "/Users/abh16/controldbagent/lib/python3.8/site-packages/s3transfer/tasks.py", line 255, in _main
self._submit(transfer_future=transfer_future, **kwargs)
File "/Users/abh16/controldbagent/lib/python3.8/site-packages/s3transfer/download.py", line 340, in _submit
response = client.head_object(
File "/Users/abh16/controldbagent/lib/python3.8/site-packages/botocore/client.py", line 386, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Users/abh16/controldbagent/lib/python3.8/site-packages/botocore/client.py", line 705, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden
Using same credentials downloading through AWS CLI works fine.