Reputation: 4255
I would like to create a bucket in GCS based in Europe using the python client.
from google.cloud import storage
storage_client = storage.Client()
bucket_name = 'my-new-bucket'
bucket = storage_client.create_bucket(bucket_name)
print('Bucket {} created.'.format(bucket.name))
This creates the bucket multiregional in the US. How can I change this to Europe?
Upvotes: 3
Views: 1538
Reputation: 1
You can try with this:
def create_bucket(bucket_name):
storage_client = storage.Client()
bucket = storage_client.create_bucket(bucket_name, location='EUROPE-WEST1')
print("Bucket {} created".format(bucket.name))
Upvotes: 0
Reputation: 38369
The create_bucket
method is limited. For more parameters, you'd create a bucket resource and invoke its create()
method, like so:
storage_client = storage.Client()
bucket = storage_client.bucket('bucket-name')
bucket.create(location='EU')
Bucket.create has a few other properties and is documented: https://googleapis.github.io/google-cloud-python/latest/storage/buckets.html#google.cloud.storage.bucket.Bucket.create
Upvotes: 5