Back to snippets

google_cloud_storage_create_bucket_quickstart.py

python

Creates a new Google Cloud Storage bucket in your project.

19d ago18 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    # The ID of your new bucket
16    # bucket_name = "your-new-bucket-name"
17    import sys
18    create_bucket(bucket_name=sys.argv[1])