Search code examples
ibm-cloudobject-storage

IBM Cloud Object Storage error creating bucket - 'creation failed, vault name invalid.'


I'm trying to create two buckets in IBM Cloud Object Storage:

cos = ibm_boto3.resource('s3',
                         ibm_api_key_id=cos_credentials['apikey'],
                         ibm_service_instance_id=cos_credentials['resource_instance_id'],
                         ibm_auth_endpoint=auth_endpoint,
                         config=Config(signature_version='oauth'),
                         endpoint_url=service_endpoint)

import datetime

# valid bucket format is ^[a-zA-Z0-9.\-_]{1,255}$
bucket_uid = datetime.datetime.now().isoformat().replace(':', '') 

buckets = ['training-data-' + bucket_uid, 'training-results-' + bucket_uid]

for bucket in buckets:
    if not cos.Bucket(bucket) in cos.buckets.all():
        print('Creating bucket "{}"...'.format(bucket))
        try:
            cos.create_bucket(Bucket=bucket)
        except ibm_boto3.exceptions.ibm_botocore.client.ClientError as e:
            print('Error: {}.'.format(e.response['Error']['Message']))

Returns the error:

Creating bucket "training-data-2018-07-11T090425.347277"...
Error: Container training-data-2018-07-11T090425.347277 creation failed, vault name invalid.
Creating bucket "training-results-2018-07-11T090425.347277"...
Error: Container training-results-2018-07-11T090425.347277 creation failed, vault name invalid.

What is the issue here? Why is the vault name invalid?

If I change the bucket_id to '12345', the buckets are created ok.


Solution

  • The bucket name length was the issue.

    Shortening the timestamp was the answer for me. It's a shame that the error message wasn't a bit more informative.