Search code examples
amazon-s3swisscomdev

S3 Python client with boto3 SDK


I'd like to make a python S3 client to store data in the S3 Dynamic Storage service provided by the appcloud. So I've discovered the boto3 SDK for python and was wondering how this thing works on the appcloud. Locally you install the aws cli to configure your credentials but how you do that on the cloud? Does someone have experience with creating a S3 python client for the internal appcloud and could provide me with a short example (boto3 or different approach)?

Greetings

Edit 1:

Tried this:

import boto3

s3 = boto3.client('s3', endpoint_url='https://ds31s3.swisscom.com/', aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET)

s3.create_bucket(Bucket="sc-testbucket1234")

But I got this exception:

botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://ds31s3.swisscom.com"

Solution

  • Works with this configuration (with python 3.5):

    import boto3
    
    conn = boto3.resource('s3', region_name='eu-west-1', endpoint_url=HOST, aws_access_key_id=KEY, aws_secret_access_key=SECRTE)
    
    conn.create_bucket(Bucket="pqdjmalsdnf12098")
    

    Thanks to @user3080315