Lab - Cloud Storage
A practice lab to understand all the features of Cloud Storage.
In the last lesson, you learned how to create and upload files to the GCS bucket using UI.
In this lab, you will use Gcloud CLI to carry out the different operations using gsutil
component of the SDK. You can use your cloud shell, laptop, or the terminal provided at the end of the lesson to complete this lab.
-
Run
gcloud init
in case you are using your laptop or terminal provided at the end of the lesson. This will configure the gcloud SDK with your GCP account. -
Run
gcloud config list
and check whether your account and project are set correctly.
root@educative:/# gcloud config list
[core]
account = gcpheadstart@gmail.com #Your email
disable_usage_reporting = True
project = gcp-headstart-educative #your project
Your active configuration is: [default]
Creating a bucket
-
Type
gsutil ls
to list existing buckets. If you get a list of buckets then the configurations are right for the project you have chosen. -
Type
gsutil mb gs://<bucketname>
. The bucket name needs to be a globally unique name. -
Type
gsutil ls
to see your newly created bucket.
Now we will upload files to the bucket.
Uploading files
There 2 ways in which you can upload a file to the bucket from your system. Using copy or move command. Both are self-explanatory. To copy, use gsutil cp [source_location] [destination]
and to
move use gsutil mv [source] [destination]
command. We will move the files for now.
-
Type
echo "demo file" >
...