This page shows you how to create a Cloud Storage bucket. If not otherwise specified in your request, buckets are created 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 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 Trusted Cloud console.)resourcemanager.projects.get
(only required if creating a bucket using the Trusted 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 Trusted Cloud console or Discover object storage with the Google Cloud CLI tool.
To create a bucket with specific settings or advanced configurations, complete the following steps:
Console
- In the Trusted 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.
To add a bucket label, click the expander arrow to expand the Labels section, click add_box Add label, and specify a
key
and avalue
for your label.
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.
To enable Anywhere Cache, select Enable Anywhere Cache.
To create caches, click Configure.
In the Configure cache settings dialog that appears, click the drop-down arrow next to the listed regions and select the zones where you want to create caches.
Click Done.
Click Continue.
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 Data encryption method.
expander arrow labeled Data encryption, and select a
Click Create.
To learn how to get detailed error information about failed Cloud Storage operations in the Trusted Cloud console, see Troubleshooting.
Command line
-
In the Trusted Cloud console, activate Cloud Shell.
At the bottom of the Trusted 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 requirements. For example,my-bucket
.BUCKET_LOCATION
is the location of your bucket. For example,U-FRANCE-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.--soft-delete-duration
: Specify a soft delete retention duration, which is the number of days you want to retain objects after they get deleted. For example,10d
.
For example:
gcloud storage buckets create gs://BUCKET_NAME --project=PROJECT_ID --default-storage-class=STORAGE_CLASS --location=BUCKET_LOCATION --uniform-bucket-level-access --soft-delete-duration=RETENTION_DURATION
For a complete list of options for bucket creation use the gcloud CLI, see
buckets create
options.
Client libraries
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.
Before running code samples, set the
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.
Before running code samples, set the
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.
Before running code samples, set the
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.
Before running code samples, set the
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.
Before running code samples, set the
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.
Before running code samples, set the
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.
Before running code samples, set the
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.
Before running code samples, set the C++
GOOGLE_CLOUD_UNIVERSE_DOMAIN
environment
variable to s3nsapis.fr
.
C#
GOOGLE_CLOUD_UNIVERSE_DOMAIN
environment
variable to s3nsapis.fr
.
Go
GOOGLE_CLOUD_UNIVERSE_DOMAIN
environment
variable to s3nsapis.fr
.
Java
GOOGLE_CLOUD_UNIVERSE_DOMAIN
environment
variable to s3nsapis.fr
.
Node.js
GOOGLE_CLOUD_UNIVERSE_DOMAIN
environment
variable to s3nsapis.fr
.
PHP
GOOGLE_CLOUD_UNIVERSE_DOMAIN
environment
variable to s3nsapis.fr
.
Python
GOOGLE_CLOUD_UNIVERSE_DOMAIN
environment
variable to s3nsapis.fr
.
Ruby
GOOGLE_CLOUD_UNIVERSE_DOMAIN
environment
variable to s3nsapis.fr
.
Terraform
You can use a Terraform resource to create a storage bucket.
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:{ "name": "BUCKET_NAME", "location": "BUCKET_LOCATION", "storageClass": "STORAGE_CLASS", "iamConfiguration": { "uniformBucketLevelAccess": { "enabled": true }, } }
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 where you want to store your bucket's object data. For example,U-FRANCE-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 $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://storage.s3nsapis.fr/storage/v1/b?project=PROJECT_IDENTIFIER"
Where:
JSON_FILE_NAME
is name of the JSON file you created in Step 2.PROJECT_IDENTIFIER
is the ID or number of the project with which your bucket will be associated. For example,my-project
.
XML API
Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorization
header.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:
<CreateBucketConfiguration> <StorageClass>STORAGE_CLASS</StorageClass> <LocationConstraint>BUCKET_LOCATION</LocationConstraint> </CreateBucketConfiguration>
Where:
STORAGE_CLASS
is the default storage class of your bucket. For example,STANDARD
.BUCKET_LOCATION
is the location where you want to store your bucket's object data. For example,U-FRANCE-EAST1
.
-
curl -X PUT --data-binary @XML_FILE_NAME \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "x-goog-project-id: PROJECT_ID" \ "https://storage.s3nsapis.fr/BUCKET_NAME"
Where:
XML_FILE_NAME
is name of the XML file you created in Step 2.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
.
If the request was successful, a response is not returned.
What's next
- List buckets in a project.
- Learn about the metadata associated with a bucket.
- Move or rename a bucket.
- Delete a bucket.
- Upload an object to your bucket.
- Create and configure buckets declaratively with the Kubernetes Config Connector, which lets you describe Trusted Cloud by S3NS resources using Kubernetes tooling, APIs, and configurations. For more information, see the Config Connector API documentation.