How do I use the AWS SDK for Python (boto3) with Tenbyte T2?
You can take advantage of Tenbyte T2 Cloud Storage using the AWS SDK for Python (boto3) alongside the Tenbyte S3-Compatible API. You need to point theendpoint_url to the Tenbyte T2 S3 endpoint of the account to which you are connecting, along with supplying an Access Key ID and Secret Access Key for the account.
Prerequisites
To use the AWS SDK for Python (boto3) with Tenbyte T2, you must:- Use AWS SDK for Python (boto3) version 1.28.0 or greater. Older versions do not support easy configuration of a custom endpoint using the service-specific endpoint feature.
- Configure the
AWS_ENDPOINT_URLenvironment variable or theendpoint_urlsetting in the shared AWS config file with your Tenbyte T2 S3 endpoint. Note: you must include thehttps://prefix in the URL, for examplehttps://t2.tenbytecloud.com. - Configure your Tenbyte T2 Access Key ID and Secret Access Key via one of the methods supported by boto3. Note: the Tenbyte T2 Access Key ID is equivalent to the AWS access key id, and the Tenbyte T2 Secret Access Key is equivalent to the AWS secret access key.
Installation
Install boto3 via pip if you havenโt already:Setting Up Environment Variables
Set the following environment variables before running your application: Linux/macOS:~/.aws/credentials and ~/.aws/config:
Example: Creating a Bucket and Uploading a File
The following example demonstrates how to create a bucket and upload data after having configuredAWS_ENDPOINT_URL, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY using either environment variables or the shared AWS config file: