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
- In the Google Cloud console, go to the Cloud Storage Buckets 
page.
 
- Click Create .
- On the Create a bucket 
page, enter your bucket information. After
    each of the following steps, click Continue 
to proceed to the next
    step: -  In the Get started section, do the following: -  Enter a globally unique name that meets the bucket name requirements . 
 
-  
-  In the Choose where to store your data section, 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. 
 
-  
 
-  
-  In the Choose how to store your data section, do the following: -  Select a default storage class for the bucket or Autoclass for automatic storage class management of your bucket's data. 
-  In the Optimize storage for data-intensive workloads section, do the following: -  To enable hierarchical namespace , select Enable Hierarchical namespace on this bucket . 
-  In the Choose how to control access to objects section, 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 data section, do the following: -  Select any of the options under Data protection that you want to set for your bucket. 
-  To enable soft delete , click expander arrow labeled soft delete policy , and specify the number of days you want to retain objects after deletion. 
-  To choose how your object data will be encrypted, click the expander arrow labeled Data encryption , 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
-  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 createcommand:gcloud storage buckets create gs:// BUCKET_NAME --location= BUCKET_LOCATION --uniform-bucket-level-access --enable-hierarchical-namespace Where: -  BUCKET_NAMEis the name you want to give your bucket, subject to naming requirements . For example,my-bucket.
-  BUCKET_LOCATIONis 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 createoptions .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 Authorizationheader.
- Create a JSON file that contains the settings for the bucket, which must include a namefor the bucket. See the Buckets: Insert documentation for a complete list of settings. The following are common settings to include:
-  BUCKET_NAMEis the name you want to give your bucket, subject to naming requirements . For example,my-bucket.
-  BUCKET_LOCATIONis the location where you want to store your bucket's object data . For example,US-EAST1.
-  STORAGE_CLASSis the default storage class of your bucket. For example,STANDARD.
-  hierarchicalNamespace.enabledis set toTRUEto enable hierarchical namespace for your bucket. You cannot enable hierarchical namespace in an existing bucket.
-  uniformBucketLevelAccess.enabledis set toTRUEto enable uniform bucket-level access for your bucket.
 
- Use  cURLto 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_NAMEis name of the JSON file that contains the bucket settings.
-  PROJECT_IDENTIFIERis the ID or number of the project that your bucket will be associated with. For example,my-project.
 
-  
{ "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 free
