How do I use the AWS SDK for Python (boto3) with Wasabi?

In order to use the AWS SDK for Python (boto3) with Wasabi, the endpoint_url has to be pointed at the appropriate service URL (for example s3.wasabisys.com for us-east or the other appropriate region service URLs) . This can be achieved by following one of the options below:

Option 1: Explicitly point the "endpoint_url" to Wasabi servers while creating the s3 resource.  Sample code to create a bucket:

 a) Create bucket in us-east-1 region


import boto3

s3 = boto3.resource('s3',
endpoint_url = 'https://s3.wasabisys.com',
aws_access_key_id = '<WASABI-ACCESS-KEY>',
aws_secret_access_key = '<WASABI-SECRET-KEY>')

s3.create_bucket(Bucket='<BUCKET-NAME>')

 b) Create bucket in us-west-1 region


import boto3

s3 = boto3.resource('s3',
endpoint_url = 'https://s3.us-west-1.wasabisys.com',
aws_access_key_id = '<WASABI-ACCESS-KEY>',
aws_secret_access_key = '<WASABI-SECRET-KEY>')

s3.create_bucket(Bucket='<BUCKET-NAME>')

Option 2: Simply use the "boto3_wasabi" module by following this documentation

Option 3: You will need to modify the session.py script to make it connect to Wasabi servers.  Using your preferred method of editing a script, open the boto3 file session.py and replace the following lines as follows

line 265
def resource(self, service_name, region_name="us-east-1", api_version=None,
                use_ssl=True, verify=None, endpoint_url="https://s3.wasabisys.com",
                aws_access_key_id=None, aws_secret_access_key=None,
                aws_session_token=None, config=None):
line 185
def client(self, service_name, region_name="us-east-1", api_version=None,
              use_ssl=True, verify=None, endpoint_url="https://s3.wasabisys.com",
              aws_access_key_id=None, aws_secret_access_key=None,
              aws_session_token=None, config=None):

When configuring the client to your personal wasabi account you should use your wasabi access key and secret key where it asks you to use your aws_access_key and aws_secret_key respectively.

Have more questions? Submit a request