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 and have a default storage class of
Standard storage.
Required roles
In order to get the required permissions for creating a Cloud Storage
bucket, ask your administrator to grant you the roles/storage.admin
IAM role on the project.
This predefined role contains the permission required to create a bucket. To see the exact permissions that are required, expand the Required permissions section:
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 other predefined roles. To see which roles are associated with which permissions, refer to IAM roles for Cloud Storage.
For instructions on granting roles to projects, see Manage access to projects.
Create a new bucket
Console
- In the Google Cloud console, go to the Cloud Storage Buckets page.
- Click + Create.
- 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 name requirements.
- For Choose where to store your data, select a Location type and Location where the bucket data will be permanently stored.
- For Choose a storage class for your data, either select a
default storage class for the bucket, or select
Autoclass for automatic storage class management of your
bucket's data.
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 whether or not your bucket
enforces public access prevention, and
select an Access control model for your
bucket's objects.
Note: If public access prevention is already enforced by your project's organization policy, the Prevent public access toggle is locked.
- For Choose how to protect object data, configure Protection tools if desired, and select a Data encryption method.
- Click Create.
To learn how to get detailed error information about failed Cloud Storage operations in the Google Cloud console, see Troubleshooting.
Command line
gcloud
-
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
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:
--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
.--location
: Specify the location of your bucket. For example,US-EAST1
.--uniform-bucket-level-access
: Enable uniform bucket-level access for your bucket.
For a complete list of options for gcloud bucket creation, see
buckets create
options.For example:
gcloud storage buckets create gs://BUCKET_NAME --project=PROJECT_ID --default-storage-class=STORAGE_CLASS --location=BUCKET_LOCATION --uniform-bucket-level-access
gsutil
-
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
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 ID or project number with which your bucket will be associated. For example,my-project
.-c
: Specify the default storage class of your bucket. For example,STANDARD
.-l
: Specify the location of your bucket. For example,US-EAST1
.-b
: Specify the uniform bucket-level access setting for your bucket. For example,ON
.
For a complete list of options for gsutil bucket creation, see mb options.
For example:
gsutil mb -p PROJECT_ID -c STORAGE_CLASS -l BUCKET_LOCATION -b on gs://BUCKET_NAME
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.
Terraform
You can use a Terraform resource to create a storage bucket.
REST APIS
JSON API
- Get an authorization access token from the OAuth 2.0 Playground. Configure the playground to use your own OAuth credentials. For instructions, see API authentication.
- 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,STANDARD
.- Use
cURL
to call the JSON API:curl -X POST --data-binary @JSON_FILE_NAME \ -H "Authorization: Bearer OAUTH2_TOKEN" \ -H "Content-Type: application/json" \ "https://storage.googleapis.com/storage/v1/b?project=PROJECT_IDENTIFIER"
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_IDENTIFIER
is the ID or number 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. For instructions, see API authentication.
- (Optional) Create an XML file that contains settings for the bucket. See the XML: Create a bucket documentation for a complete list of settings. The following are common settings to include:
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,STANDARD
.- Use
cURL
to call the XML API:curl -X PUT --data-binary @XML_FILE_NAME \ -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 information about a bucket's metadata.
- Move or rename a bucket.
- Delete a bucket.
- Upload an object to your bucket.
- Manage bucket creation and configuration with the Kubernetes Config Connector.
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