What is a Google storage bucket?
Buckets are the basic containers that hold your data. Everything that you store in Cloud Storage must be contained in a bucket. You can use buckets to organize your data and control access to your data, but unlike directories and folders, you cannot nest buckets.
In this demonstration, we will be creating a storage bucket using “Cloud Console” and “Cloud Shell”.
1. Use the “Cloud Console” to create a bucket
In this task, We will create a Storage bucket Using Google cloud Console.
Navigate to the Storage service and create the bucket
- In the Cloud Console, on the Navigation menu, click Storage > Browser.
2. Click Create bucket.
3. For Name, type a globally unique bucket name; leave all other values as their defaults. Click Create.
4. You will see your Storage Bucket has been Created.
Congratulations !! Your storage Bucket has been created.
Now we will see how to use a similar storage bucket using “Google Cloud Shell” which is a command-line tool.
2. Use “Cloud Shell” to create a Cloud Storage bucket
Create a second bucket and verify in the Cloud Console
5. Open Cloud Shell again. In the Google Cloud menu, click Activate Cloud Shell. If prompted, click Continue.
6. Use the gsutil command to create another bucket.
Replace <BUCKET_NAME> with a globally unique name
gsutil mb gs://<BUCKET_NAME>
7. In the Cloud Console, on the Navigation menu, click Storage > Browser, or click Refresh if you are already in the Storage browser. The second bucket should be displayed in the Buckets list.
You have performed equivalent actions using the Cloud Console and Cloud Shell. You created a bucket using the Cloud Console and another bucket using Cloud Shell.
3. Explore more Cloud Shell features
Now since we have created our storage bucket, let’s explore a bit more by uploading a file from our laptop to the storage bucket. To Achieve this, please perform the below steps:
8. Open Cloud Shell.
9. Click the More button in the Cloud Shell toolbar to display further options.
10. Click Upload file. Upload any file from your local machine to the Cloud Shell VM. For our demonstration, we will be uploading “images.png”.
11. In Cloud Shell, type
ls -l to confirm that the file was uploaded.
12. Copy the file into one of the buckets you created earlier in the lab. Replace [MY_FILE] with the file you uploaded and [BUCKET_NAME] with one of your bucket names:
gsutil cp [MY_FILE] gs://[BUCKET_NAME]
13. If your filename has whitespaces, be sure to place single quotes around the filename. For example,
gsutil cp ‘my file.txt' gs://[BUCKET_NAME]
You have uploaded a file to the Cloud Shell VM and copied it to a bucket.
Explore the options available in Cloud Shell by clicking on different icons in the Cloud Shell toolbar.
This concludes our tutorial for Creating a Storage Bucket using “Cloud Console” and “Cloud Shell”.