This page describes how to create buckets with hierarchical namespace enabled.
Required roles
To get the permission that
you need to create a bucket with hierarchical namespace enabled,
ask your administrator to grant you the
Storage Admin (roles/storage.admin
)
IAM role on the project.
For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the
storage.buckets.create
permission,
which is required to
create a bucket with hierarchical namespace enabled.
You might also be able to get this permission with custom roles or other predefined roles.
Create a bucket with hierarchical namespace enabled
Console
To enable hierarchical namespace on a bucket, start by following the steps to create a new bucket, and then do the following:
- In the Choose how to store your data section, locate the Optimize storage for data-intensive workloads section, and then select Enable Hierarchical namespace on this bucket.
- Complete the remaining steps to finish creating your bucket.
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 --uniform-bucket-level-access --enable-hierarchical-namespace
Where:
BUCKET_NAME
is the name you want to give your bucket, subject to naming requirements. For example,my-bucket
.BUCKET_LOCATION
is the location of your bucket. For example,us-east1
.--uniform-bucket-level-access
: Enable uniform bucket-level access for the bucket.
--enable-hierarchical-namespace
: Enable hierarchical namespace for the bucket. You cannot enable hierarchical namespace in an existing bucket.
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 that your bucket will be associated with. For example,my-project
.--default-storage-class
: Specify the default storage class of your bucket. For example,STANDARD
.
For a complete list of options for creating buckets using the Google Cloud CLI, 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
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 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 client libraries.
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 client libraries.
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 client libraries.
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 client libraries.
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 client libraries.
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 client libraries.
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 client libraries.
REST APIs
JSON API
Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorization
header.- 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
.hierarchicalNamespace.enabled
is set toTRUE
to enable hierarchical namespace for your bucket. You cannot enable hierarchical namespace in an existing bucket.uniformBucketLevelAccess.enabled
is set toTRUE
to enable uniform bucket-level access for your bucket.
- Use
cURL
to call the JSON API:curl -X POST --data-binary @JSON_FILE_NAME \ -H "Authorization: Bearer $(gcloud auth print-access-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 that contains the bucket settings.PROJECT_IDENTIFIER
is the ID or number of the project that your bucket will be associated with. For example,my-project
.
- Use
{ "name": "BUCKET_NAME", "location": "BUCKET_LOCATION", "storageClass": "STORAGE_CLASS", "hierarchicalNamespace": { "enabled": "BOOLEAN" }, "iamConfiguration": { "uniformBucketLevelAccess": { "enabled": true }, }, }
Where:
What's next
- Understand folders.
- Create and manage folders.
- Get a bucket's metadata.
- Get a bucket's storage layout.
- List and delete buckets.
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 freeExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-04 UTC.