Manage Google Cloud Storage GCS buckets with Cloud Shell
Google Cloud Storage (GCS) offers a scalable and secure solution for managing data in the cloud. In this article we will see how to create and remove a bucket using Google Cloud Shell, an integrated and handy tool for performing operations directly on the Google Cloud platform.
Introduction to Google Cloud Shell
Google Cloud Shell is an interactive tool that allows you to execute commands for managing Google Cloud services, including creating and deleting buckets in Google Cloud Storage. Using Cloud Shell is advantageous because it requires no additional configuration: you can start the session directly from the browser and access all Google Cloud SDK features.
Create a bucket on Google Cloud Storage
Creating a bucket on Google Cloud Storage is quick and easy. Make sure you have an active project and the necessary permissions to create resources.
- Log in to Google Cloud Shell and open a new session.
- Use the
gsutil
command to create a bucket:
gsutil mb -l REGION gs:/_BUCKET NAME.
Replace REGION
with the desired region (e.g., eu-west8
) and_BUCKET N
AME with the name you prefer. The mb
command stands for "make bucket," thus creating a new space for your data.
Deleting a bucket on Google Cloud Storage
To delete a bucket, it must be empty. If it contains files, those files must be removed before you can proceed with deleting the bucket.
- To delete all files in a bucket, use:
gsutil rm -r gs://BUCKET NAME.
- Once emptied, you can remove the bucket with the following command:
gsutil rb gs://NAME_BUCKET
The rb
(remove bucket) command allows you to permanently delete the specified bucket.
Advanced bucket management on Google Cloud Storage.
Cloud Shell offers multiple commands for advanced bucket management. Some useful commands include:
- View existing buckets:
gsutil ls
- Set specific permissions
: gsutil iam ch
to configure access permissions. - Copy files to/from the bucket: Use
gsutil cp
to transfer files.
Explore the full gsutil documentation for more management options.
Support for Google Cloud
Turn to our experienced Google Cloud team. Now Free 30m of analysis and consulting!
Frequently Asked Questions (FAQs).
How can I choose the region of my bucket?
The region can be specified in the bucket creation command. For example, gsutil mb -l eu-west8 gs://my-bucket
will create a bucket in the 'eu-west8' region of Milan.
Can I use Google Cloud Shell without configuration?
Yes, Google Cloud Shell is preconfigured with all the tools you need to perform operations on Google Cloud. Just open it from your browser and start working.
How can I assign permissions to a bucket?
You can use gsutil iam ch
to set specific permissions, such as assigning roles to users or groups to manage access to the bucket.