LogoLogo
  • How to use Google cloud
  • Buckets
    • Creating storage buckets  |  Cloud Storage  |  Google Cloud
    • gsutil commands
    • rsync - Synchronize content of two buckets/directories  |  Cloud Storage
  • Mapping bucket to the local instance on google cloud
Powered by GitBook
On this page
  • Console
  • gsutil
  • Code samples
  • REST APIS
  • JSON API
  • XML API

Was this helpful?

  1. Buckets

Creating storage buckets  |  Cloud Storage  |  Google Cloud

Imported from google doc (always check for there for updates)

PreviousHow to use Google cloudNextgsutil commands

Last updated 5 years ago

Was this helpful?

This page shows you how to create Cloud Storage buckets. For an overview of buckets, read the . If not otherwise specified in your request, buckets are created in the and have a default storage class of .

Console

  1. Open the Cloud Storage browser in the Google Cloud Console.

  2. Click Create bucket to open the bucket creation form.

  3. Enter your bucket information and click Continue to complete each step:

    • Specify a Name, subject to the .

    • Select a Default storage class for the bucket. The default will be assigned by default to all objects uploaded to the bucket. Next, select a Location where the bucket data will be permanently stored.

      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.

    • Select an Access control model to determine how you to the bucket's objects.

    • Optionally, you can add , set a , and choose an .

  4. Click Done.

gsutil

Use the command:

gsutil mb gs://[BUCKET_NAME]/

Where:

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.

For example:

  gsutil mb -p [PROJECT_ID] -c [STORAGE_CLASS] -l [BUCKET_LOCATION] -b on gs://[BUCKET_NAME]/

Code samples

REST APIS

JSON API

  1. Create a .json file that contains the following information:

    {
      "name": "[BUCKET_NAME]",
      "location": "[BUCKET_LOCATION]",
      "storageClass": "[STORAGE_CLASS]"
    }

    Where:

  2. 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.

XML API

  1. Create a .xml file that contains the following information:

    <CreateBucketConfiguration>
       <LocationConstraint>[BUCKET_LOCATION]</LocationConstraint>
       <StorageClass>[STORAGE_CLASS]</StorageClass>
    </CreateBucketConfiguration>

    Where:

  2. 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 . For example, my-bucket.

-c: Specify the default of your bucket. For example, NEARLINE.

-l: Specify the of your bucket. For example, US-EAST1.

-b: Enable for your bucket.

Get an authorization access token from the . Configure the playground to use your own OAuth credentials.

[BUCKET_NAME] is the name you want to give your bucket, subject to . For example, my-bucket.

[BUCKET_LOCATION] is the where you want to store your bucket's . For example, US-EAST1.

[STORAGE_CLASS] is the default of your bucket. For example, NEARLINE.

Use to call the :

Get an authorization access token from the . Configure the playground to use your own OAuth credentials.

[BUCKET_LOCATION] is the where you want to store your bucket's . For example, US-EAST1.

[STORAGE_CLASS] is the default of your bucket. For example, NEARLINE.

Use to call the :

[BUCKET_NAME] is the name you want to give your bucket, subject to . For example, my-bucket.

Key Terms
US multi-region
Standard Storage
Open the Cloud Storage browser
bucket name requirements
storage class
control access
bucket labels
retention policy
encryption method
gsutil mb
naming requirements
storage class
location
uniform bucket-level access
OAuth 2.0 Playground
naming requirements
location
object data
storage class
cURL
JSON API
OAuth 2.0 Playground
location
object data
storage class
cURL
XML API
naming requirements