This page shows you how to create Cloud Storage buckets
. If not
otherwise specified in your request, buckets are created in the US
multi-region
with a default storage class of Standard storage
and have a seven-day soft delete
retention duration.
Required roles
In order to get the required permissions for creating a Cloud Storage
bucket, ask your administrator to grant you the Storage Admin
( roles/storage.admin
) IAM role for the project.
This predefined role contains the permission required to create a bucket. To see the exact permissions that are required, expand the Required permissionssection:
Required permissions
-
storage.buckets.create
-
storage.buckets.enableObjectRetention
(only required if enabling object retention configurations for the bucket) -
storage.buckets.list
(only required if creating a bucket using the Google Cloud console) -
resourcemanager.projects.get
(only required if creating a bucket using the Google Cloud console)
You might also be able to get these permissions with custom roles or other predefined roles. To see which roles are associated with which permissions, refer to IAM roles for Cloud Storage .
For instructions on granting roles for projects, see Manage access to projects .
Create a new bucket
If you are creating a bucket for the first time, see Discover object storage with the Google Cloud console or Discover object storage with the Google Cloud CLI tool .
To create buckets with specific settings or advanced configurations, complete the following steps:
Console
- In the Google Cloud console, go to the Cloud Storage Buckets
page.
-
Click Create.
-
On the Create a bucketpage, enter your bucket information. After each of the following steps, click Continueto proceed to the next step:
-
In the Get startedsection, do the following:
- Enter a globally unique name that meets the bucket name requirements .
-
To enable hierarchical namespace ( preview ), click the expander arrow to expand the Optimize for file oriented and data-intensive workloadssection, and then select Enable Hierarchical namespace on this bucket.
-
To add a bucket label , click the expander arrow to expand the Labelssection, click add_box Add label, and specify a
key
and avalue
for your label.
-
In the Choose where to store your datasection, do the following:
-
Select a Location type .
-
Use the location type's drop-down menu to select a Location where object data within your bucket will be permanently stored.
- If you select the dual-region location type, you can also choose to enable turbo replication by using the relevant checkbox.
-
To set up cross-bucket replication , expand the Set up cross-bucket replicationsection and follow the steps:
Set up cross-bucket replication
- Select the checkbox next to Add cross-bucket replication via Storage Transfer Service .
- In the Destination bucket menu, select a destination bucket.
-
Optional: In the Replication settings section, click Configure to configure settings for the replication job.
The Configure cross-bucket replication pane appears.
- To filter objects to replicate by object name prefix, enter a prefix with which you want to include or exclude objects, then click Add a prefix .
- To set a storage class for the replicated objects, select a storage class from the Storage class menu. If you skip this step, the replicated objects will use the destination bucket's storage class by default.
- Click Done .
-
-
In the Choose a storage class for your datasection, either select a default storage class for the bucket, or select Autoclass for automatic storage class management of your bucket's data.
-
In the Choose how to control access to objectssection, select whether or not your bucket enforces public access prevention , and select an access control model for your bucket's objects.
-
In the Choose how to protect object datasection, do the following:
-
Select any of the options under Data protectionthat you want to set for your bucket.
-
To choose how your object data will be encrypted, click the expander arrow labeled Data encryption, and select a Data encryptionmethod .
-
-
-
Click Create.
To learn how to get detailed error information about failed Cloud Storage operations in the Google Cloud console, see Troubleshooting .
Command line
-
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
-
In your development environment, run the
gcloud storage buckets create
command:gcloud storage buckets create gs:// BUCKET_NAME --location= BUCKET_LOCATION
Where:
-
BUCKET_NAME
is the name you want to give your bucket, subject to naming requirement . For example,my-bucket
. -
BUCKET_LOCATION
is the location of your bucket. For example,us-east1
.
If the request is successful, the command returns the following message:
Creating gs:// BUCKET_NAME /...
Set the following flags to have greater control over the creation of your bucket:
-
--project
: Specify the project ID or project number with which your bucket will be associated. For example,my-project
. -
--default-storage-class
: Specify the default storage class of your bucket. For example,STANDARD
. -
--uniform-bucket-level-access
: Enable uniform bucket-level access for your bucket.
For example:
gcloud storage buckets create gs:// BUCKET_NAME --project= PROJECT_ID --default-storage-class= STORAGE_CLASS --location= BUCKET_LOCATION --uniform-bucket-level-access
For a complete list of options for bucket creation use the gcloud CLI, see
buckets create
options . -
Client libraries
C++
For more information, see the Cloud Storage C++ API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for a local development environment .
C#
For more information, see the Cloud Storage C# API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for a local development environment .
Go
For more information, see the Cloud Storage Go API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for a local development environment .
Java
For more information, see the Cloud Storage Java API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for a local development environment .
Node.js
For more information, see the Cloud Storage Node.js API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for a local development environment .
PHP
For more information, see the Cloud Storage PHP API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for a local development environment .
Python
For more information, see the Cloud Storage Python API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for a local development environment .
Ruby
For more information, see the Cloud Storage Ruby API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for a local development environment .