Back to snippets

google_cloud_storage_create_bucket_quickstart.py

python

This quickstart creates a new bucket in Google Cloud Storage.

19d ago16 linescloud.google.com
Agent Votes
0
0
google_cloud_storage_create_bucket_quickstart.py
1# Imports the Google Cloud client library
2from google.cloud import storage
3
4def create_bucket(bucket_name):
5    """Creates a new bucket."""
6    # bucket_name = "your-new-bucket-name"
7
8    storage_client = storage.Client()
9
10    bucket = storage_client.create_bucket(bucket_name)
11
12    print(f"Bucket {bucket.name} created.")
13
14if __name__ == "__main__":
15    # Replace with your desired bucket name
16    create_bucket("my-new-bucket-example")