How to Create Buckets (mb) with the gsutil Utility

By Matthew Scarpino

Before you upload data to Cloud Storage, you need to create one or more buckets. The command to know is mb:

gsutil mb [-c class] [-l location] [-p project_id] url…

The –c, –l, and –p flags are particularly important:

  • -c: The bucket’s storage class: multi_regional, regional, nearline, and coldline. (Default: multi_regional or regional).
  • -l: The bucket’s multi-regional location or regional location. (Default: us).
  • -p: The project’s ID. (Default: the ID in the gsutil configuration file).

For example, the following command creates a regional bucket named gs://dummies123-tfbook/example and associates it with the us-central1 region.

gsutil mb -c regional -l us-central1 gs://dummies123-tfbook/example