mb - Make buckets

Synopsis

gsutil mb [-b (on|off)] [-c <class>] [-k <key>] [-l <location>] [-p <project>]
          [--autoclass] [--retention <time>] [--pap <setting>]
          [--placement <region1>,<region2>]
          [--rpo (ASYNC_TURBO|DEFAULT)] gs://<bucket_name>...

Description

Create one or more new buckets. Cloud Storage has a single namespace, so you are not allowed to create a bucket with a name already in use by another user. You can, however, carve out parts of the bucket name space corresponding to your company's domain name (see "gsutil help naming").

If you don't specify a project ID or project number using the -p option, the buckets are created using the default project ID specified in your gsutil configuration file.

The -l option specifies the location for the buckets. Once a bucket is created in a given location, it cannot be moved to a different location. Instead, you need to create a new bucket, move the data over, and then delete the original bucket.

Bucket Storage Classes

You can specify one of the storage classes for a bucket with the -c option.

Example:

gsutil mb -c nearline gs://some-bucket

See online documentation for pricing and SLA details.

If you don't specify a -c option, the bucket is created with the default storage class Standard Storage.

Bucket Locations

You can specify one of the available locations for a bucket with the -l option.

Examples:

gsutil mb -l asia gs://some-bucket

gsutil mb -c standard -l us-east1 gs://some-bucket

If you don't specify a -l option, the bucket is created in the default location (US).

Retention Policy

You can specify retention period in one of the following formats:

--retention <number>s

Specifies retention period of <number> seconds for objects in this bucket.

--retention <number>d

Specifies retention period of <number> days for objects in this bucket.

--retention <number>m

Specifies retention period of <number> months for objects in this bucket.

--retention <number>y

Specifies retention period of <number> years for objects in this bucket.

Examples:

gsutil mb --retention 1y gs://some-bucket

gsutil mb --retention 36m gs://some-bucket

If you don't specify a --retention option, the bucket is created with no retention policy.

Options

--autoclass

Enables the Autoclass feature that automatically sets object storage classes.

-b <on|off>

Specifies the uniform bucket-level access setting. When "on", ACLs assigned to objects in the bucket are not evaluated. Consequently, only IAM policies grant access to objects in these buckets. Default is "off".

-c class

Specifies the default storage class. Default is Standard. See Available storage classes for a list of possible values.

-k <key>

Set the default KMS key using the full path to the key, which has the following form: projects/[project-id]/locations/[location]/keyRings/[key-ring]/cryptoKeys/[my-key]

-l location

Can be any supported location. See https://cloud.google.com/storage/docs/locations for a discussion of this distinction. Default is US. Locations are case insensitive.

-p project

Specifies the project ID or project number to create the bucket under.

-s class

Same as -c.

--retention time

Specifies the retention policy. Default is no retention policy. This can only be set on gs:// buckets and requires using the JSON API. For more details about retention policy see gsutil help retention

--pap setting

Specifies the public access prevention setting. Valid values are "enforced" or "inherited". When "enforced", objects in this bucket cannot be made publicly accessible. Default is "inherited".

--placement reg1,reg2

Two regions that form the custom dual-region. Only regions within the same continent are or will ever be valid. Invalid location pairs (such as mixed-continent, or with unsupported regions) will return an error.

--rpo setting

Specifies the replication setting. This flag is not valid for single-region buckets, and multi-region buckets only accept a value of DEFAULT. Valid values for dual region buckets are (ASYNC_TURBO|DEFAULT). If unspecified, DEFAULT is applied for dual-region and multi-region buckets.