For the complete documentation index, see llms.txt. This page is also available as Markdown.

Boto3 Python SDK

Boto3 is the official AWS SDK for Python. It lets you create, update, and configure IONOS CLOUD Object Storage objects within your Python scripts.

Configuration

  • Install the latest Boto3 release via pip: pip install boto3.

There are several ways to provide credentials, such as passing them as parameters to the boto.client() method, via environment variables, or with a generic credential file (~/.aws/credentials). For more information, see Credentials.

Example of passing credentials as parameters when creating a Session object

To get the Access Key and Secret Key, see Generate a Key.

Note:

  • Your credentials are not tied to a specific region or bucket.

  • For information on the supported IONOS CLOUD Object Storage service endpoints, see Endpoints.

import boto3
import logging
from botocore.exceptions import ClientError
from botocore.client import Config

config = Config(
   signature_version = 's3v4'
)

s3_client = boto3.client('s3',
                         endpoint_url='https://s3.eu-central-2.ionoscloud.com',
                         aws_access_key_id='YOUR_ACCESS_KEY',
                         aws_secret_access_key='YOUR_SECRET_KEY',
                         config=config)

Example

  • List buckets:

  • Create bucket my-bucket at the region eu-central-1:

  • Upload filename.txt to the bucket my-bucket:

    For more information, see AWS SDK documentation on Uploading files.

  • Download the file filename.txt from the my-bucket:

  • List objects of the bucket my-bucket

  • Copy the filename.txt from the bucket my-source-bucket to the bucket my-dest-bucket and add the prefix uploaded/. We use the resource() method instead of the client() method here. It provides a higher level of abstraction than the low-level calls made by service clients.

For more examples, refer to Boto3 Documentation, such as:

For more information on Boto3 and Python, see Realpython.com – Python, Boto3, and AWS S3: Demystified.

Last updated

Was this helpful?