1
votes

I am using the python client library for the Google Storage API, and I have a file, pythonScript.py, that has the contents:

# Imports the Google Cloud client library
from google.cloud import storage

# Instantiates a client
storage_client = storage.Client()

# The name for the new bucket
bucket_name = 'my-new-bucket'

# Creates the new bucket
bucket = storage_client.create_bucket(bucket_name)

print('Bucket {} created.'.format(bucket.name))

When I try to run it I get this in the terminal:

Traceback (most recent call last): File "pythonScript.py", line 11, in bucket = storage_client.create_bucket(bucket_name) File "/home/joel/MATI/env/lib/python3.5/site-packages/google/cloud/storage/client.py", line 218, in create_bucket bucket.create(client=self) File "/home/joel/MATI/env/lib/python3.5/site-packages/google/cloud/storage/bucket.py", line 199, in create data=properties, _target_object=self) File "/home/joel/MATI/env/lib/python3.5/site-packages/google/cloud/_http.py", line 293, in api_request raise exceptions.from_http_response(response) google.cloud.exceptions.Conflict: 409 POST https://www.googleapis.com/storage/v1/b?project=avid-folder-180918: Sorry, that name is not available. Please try a different one.

I am not sure why, since I do have the GSS API enabled for my project, and the default configuration seems to be correct. The out output of gcloud config list is:

[compute]

region = us-east1

zone = us-east1-d

[core] account = [email protected]

disable_usage_reporting = True

project = avid-folder-180918

Your active configuration is: [default]

1
GCS has a global namespace of buckets (shared across all GCS users), and that bucket name ("my-new-bucket") already exists. You need to pick a different name.Mike Schwartz

1 Answers

7
votes

Bucket names are globally unique. Someone else must already own the bucket named "my-new-bucket."