Following IBM documentation, I'm trying to list objects in my COS bucket using Python and ibm-cos-sdk.
import ibm_boto3
from ibm_botocore.client import Config, ClientError
cos = ibm_boto3.resource("s3",
ibm_api_key_id=params['API_KEY'],
ibm_service_instance_id=params['COS_TGT_INSTANCE_CRN'],
ibm_auth_endpoint=params['IAM_ENDPOINT'],
config=Config(signature_version="oauth"),
endpoint_url=params['COS_ENDPOINT']
)
for obj in cos.Bucket('sql-efbfb11b-fa01-4c49-8fe1-c70793be3f5f').objects.all():
print(obj.key)
Which results in:
ibm_botocore.errorfactory.NoSuchBucket: An error occurred (NoSuchBucket) when calling the ListObjects operation: The specified bucket does not exist.
I'm pretty sure the bucket does exist, because I can clearly see it in the output from
>>> for b in cos.buckets.all():
... print(b.name)
...
sql-efbfb11b-fa01-4c49-8fe1-c70793be3f5f
What am I doing wrong here?