I've seen a lot of people have problems with this online and now I've run into the issue myself. I'm trying to use boto3 to list_buckets in a DigitalOcean Spaces. It returns a 200 status code, however there are no buckets listed inside. Strangely enough, I can create a bucket through code, but I can't list it.
People have reported having success when they use different endpoint URLs. I've used the following:
https://<space_name>.nyc3.digitaloceanspaces.com
https://nyc3.digitaloceanspaces.com
No luck with either of them.
import boto3
s3 = boto3.client('s3', region_name=region, endpoint_url=endpoint, aws_access_key_id=access_id, aws_secret_access_key=secret_key)
s3.list_buckets()
list_buckets
returns the following response.
{'ResponseMetadata': {'RequestId': 'tx00000000000010c9ce0be-0061b571d4-1800930a-nyc3c', 'HostId': '', 'HTTPStatusCode': 200, 'HTTPHeaders': {'transfer-encoding': 'chunked', 'x-amz-request-id': 'tx00000000000010c9ce0be-0061b571d4-1800930a-nyc3c', 'content-type': 'application/xml', 'date': 'Sun, 12 Dec 2021 03:51:48 GMT', 'strict-transport-security': 'max-age=15552000; includeSubDomains; preload'}, 'RetryAttempts': 0}}
I figured it out. I created my DigitalOcean space and called it foobar-development
. I set the endpoint='https://nyc3.digitaloceanspaces.com'
. When I did a list_buckets
, and I got a response that contained my spaces name foobar-development
. So it appears that "bucket" and "space" are synonymous. I thought they were separate and that I would create the bucket in the space and then access it, but no. That's not how it works.