With s3cmd I am able to connect to a bucket with the following config file:
[default]
access_key = <VARIABLE>
secret_key = <VARIABLE>
host_base = <VARIABLE>
host_bucket = <VARIABLE>
use_https = True
I'd rather build a Python script to connect to a S3 bucket instead of s3cmd and am looking at boto3 right now. However I cannot find a way to define the host_bucket variable. I am currently using the following code:
import boto3
s3 = boto3.resource(
's3',
aws_access_key_id=<VARIABLE>,
aws_secret_access_key=<VARIABLE>,
endpoint_url=<VARIABLE>
)
for bucket in s3.buckets.all():
print(bucket, bucket.name)
This returns zero.
With your CMD use
aws configurethen you need to fill in the infos.after in your code use
and something like this:
see the documentation