In this blog we will see how to create a Google Cloud Bucket using Google Cloud Shell.Also I will add some object to that bucket using cloud shell.So stay tuned till the end.
What Is Object Storage?
In object storage, files are simply referenc as objects and organize into buckets—logical namespaces that are able to hold one or more objects. While a bucket can have multiple objects, an object can only belong to just one bucket. The object storage service offered by Google Cloud is called Google Cloud Storage.
How to Use the gsutil Command-Line Tool
In this section we are going to explore how the gsutil command-line tool works in practice. This tool can help with the transfer of several objects, including folders, and is also well suited for automating tasks that are not so easy to achieve via the Google Cloud Console.
Creating a Google Cloud Storage Bucket with gsutil in Google Cloud Shell
GCP buckets are use to store files and data’s which can be save and it can access from cloud console. We can upload the files into bucket and we can use that data for our calculation purposes.
On the Google Cloud Platform menu, click Activate Cloud Shell . If a dialog box appears, click Continue.
For convenience, enter your chosen location into an environment variable called LOCATION.
Creating the Google Cloud Storage bucket is quite simple. Use the below command to create it. It’s name must be globally unique.
gsutil mb -l $LOCATION gs://$DEVSHELL_PROJECT_ID
In Cloud Shell, the DEVSHELL_PROJECT_ID environment variable contains your project ID.I have used DEVSHELL_PROJECT_ID for globally unique bucket name.
To verify that my your bucket is create or not go to cloud console after that Navigate menu -> Cloud Storage -> Browser. You will find your Bucket.
Adding/Removing Data from a Google Storage Bucket with gsutil in Google Cloud Shell
The process of adding and removing data from a Google storage bucket is quite simple and fast, with the only potential bottleneck being the speed of your internet connection.
If you have use the terminal, you may be familiar with the concept of the commands cp (copy) and rm (remove). The Google Cloud Storage command-line tool gsutil uses the exact same concept.
Here I am retrieving a banner image from a publicly accessible Cloud Storage location:
gsutil cp gs://cloud-training/gcpfci/my-excellent-blog.png my-excellent-blog.png
Now copy the banner image to your newly created Cloud Storage bucket:
gsutil cp my-excellent-blog.png gs://$DEVSHELL_PROJECT_ID/my-excellent-blog.png
You can verify the files were properly create by using the following command and list the contents of the bucket .
gsutil ls gs://$DEVSHELL_PROJECT_ID
Likewise, if you wish to remove the objects from the storage bucket, you can issue the command gsutil rm gs://<YOUR_BUCKET_NAME>/* to remove all the files inside the bucket.
Clean up the environment by deleting the Cloud Storage bucket you created, by using the subcommand rb (remove bucket), i.e., with the command gsutil rb gs://<YOUR_BUCKET_NAME>.
If you want to learn more thing go to knoldus blog using below link:
That’s all for this blog.Thank you for sticking to the end. If you like this blog, please do show your appreciation by giving thumbs-ups and share this blog and give me suggestions on how I can improve my future posts to suit your needs.