This page shows you how to create Cloud Storage buckets. For an
overview of buckets, read the Key Terms. If not otherwise specified in your
request, buckets are created in the US
multi-region and have a default
storage class of Standard Storage.
To create a new storage bucket:
Console
- In the Google Cloud Console, go to the Cloud Storage Browser page.
- Click Create bucket.
- On the Create a bucket page, enter your bucket information. To go to the
next step, click Continue.
- For Name your bucket, enter a name that meets the bucket naming requirements.
- For Choose where to store your data, select a Location type and Location option where the bucket data will be permanently stored.
- For Choose a default storage class for your data, select a
storage class
for the bucket. The default storage class is
assigned by default to all objects uploaded to the bucket.
Note: The Monthly cost estimate panel in the right pane estimates the bucket's monthly costs based on your selected storage class and location, as well as your expected data size and operations.
- For Choose how to control access to objects, select an Access control option. The access control model determines how you control access to the bucket's objects.
- For Advanced settings (optional), add bucket labels, set a retention policy, and choose an encryption method.
- Click Create.
To learn how to get detailed error information about failed operations in the Cloud Storage browser, see Troubleshooting.
gsutil
Use the gsutil mb
command:
gsutil mb gs://BUCKET_NAME
Where:
BUCKET_NAME
is the name you want to give your bucket, subject to naming requirements. For example,my-bucket
.
If the request is successful, the command returns the following message:
Creating gs://BUCKET_NAME/...
Set the following optional flags to have greater control over the creation of your bucket:
-p
: Specify the project with which your bucket will be associated. For example,my-project
.-c
: Specify the default storage class of your bucket. For example,NEARLINE
.-l
: Specify the location of your bucket. For example,US-EAST1
.-b
: Enable uniform bucket-level access for your bucket.
For example:
gsutil mb -p PROJECT_ID -c STORAGE_CLASS -l BUCKET_LOCATION -b on gs://BUCKET_NAME
Code samples
C++
For more information, see the Cloud Storage C++ API reference documentation.
C#
For more information, see the Cloud Storage C# API reference documentation.
Go
For more information, see the Cloud Storage Go API reference documentation.
Java
For more information, see the Cloud Storage Java API reference documentation.
Node.js
For more information, see the Cloud Storage Node.js API reference documentation.
PHP
For more information, see the Cloud Storage PHP API reference documentation.
Python
For more information, see the Cloud Storage Python API reference documentation.
Ruby
For more information, see the Cloud Storage Ruby API reference documentation.
REST APIS
JSON API
- Get an authorization access token from the OAuth 2.0 Playground. Configure the playground to use your own OAuth credentials.
- Create a .json file that contains the settings for the bucket, which must include a
name
for the bucket. See the Buckets:Insert documentation for a complete list of settings. The following are common settings to include: BUCKET_NAME
is the name you want to give your bucket, subject to naming requirements. For example,my-bucket
.BUCKET_LOCATION
is the location where you want to store your bucket's object data. For example,US-EAST1
.STORAGE_CLASS
is the default storage class of your bucket. For example,NEARLINE
.- Use
cURL
to call the JSON API:curl -X POST --data-binary @JSON_FILE_NAME.json \ -H "Authorization: Bearer OAUTH2_TOKEN" \ -H "Content-Type: application/json" \ "https://storage.googleapis.com/storage/v1/b?project=PROJECT_ID"
Where:
JSON_FILE_NAME
is name of the JSON file you created in Step 2.OAUTH2_TOKEN
is the access token you generated in Step 1.PROJECT_ID
is the ID of the project with which your bucket will be associated. For example,my-project
.
{ "name": "BUCKET_NAME", "location": "BUCKET_LOCATION", "storageClass": "STORAGE_CLASS", "iamConfiguration": { "uniformBucketLevelAccess": { "enabled": true }, } }
Where:
XML API
- Get an authorization access token from the OAuth 2.0 Playground. Configure the playground to use your own OAuth credentials.
- Create a .xml file that contains the following information:
BUCKET_LOCATION
is the location where you want to store your bucket's object data. For example,US-EAST1
.STORAGE_CLASS
is the default storage class of your bucket. For example,NEARLINE
.- Use
cURL
to call the XML API:curl -X PUT --data-binary @XML_FILE_NAME.xml \ -H "Authorization: Bearer OAUTH2_TOKEN" \ -H "x-goog-project-id: PROJECT_ID" \ "https://storage.googleapis.com/BUCKET_NAME"
Where:
XML_FILE_NAME
is name of the XML file you created in Step 2.OAUTH2_TOKEN
is the access token you generated in Step 1.PROJECT_ID
is the ID of the project with which your bucket will be associated. For example,my-project
.BUCKET_NAME
is the name you want to give your bucket, subject to naming requirements. For example,my-bucket
.
<CreateBucketConfiguration> <LocationConstraint>BUCKET_LOCATION</LocationConstraint> <StorageClass>STORAGE_CLASS</StorageClass> </CreateBucketConfiguration>
Where:
What's next
- List buckets in a project.
- Get bucket information.
- Move or rename a bucket.
- Delete a bucket.
- Upload an object to your bucket.
- Learn the basics of using Cloud Storage with the Google Cloud Console.
Try it for yourself
If you're new to Google Cloud, create an account to evaluate how Cloud Storage performs in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
Try Cloud Storage free