GSP695
Overview
In this lab, you use gcloud storage to create a bucket and perform operations on objects. gcloud storage is part of the Google Cloud CLI that lets you access Cloud Storage from the command line, providing unified syntax and high-performance parallel transfers. The gcloud storage tool has subcommands such as buckets create and cp to perform operations. Each command has a set of options that you can use to customize settings further.
What you'll learn
In this lab, you learn how to perform the following tasks:
- Create a bucket
- Copy files from a local folder to a bucket
- Synchronize the contents of the local folder with the contents of the bucket
- Change access control permissions on objects
Setup and requirements
- Labs are timed and cannot be paused. The timer starts when you click Start Lab.
- The included cloud terminal is preconfigured with the gcloud SDK.
- Use the terminal to execute commands and then click Check my progress to verify your work.
Get the sample code and set variables
- In the cloud terminal session, execute the following command to download sample data from the pre-provisioned assets bucket:
gcloud storage cp -r gs://{{{project_0.startup_script.assets_bucket | PROJECT_ID-assets}}}/* .
- Set some environment variables:
PROJECT_ID=$(gcloud config get-value project)
BUCKET=${PROJECT_ID}-bucket
Task 1. Create a bucket
- Run the following command to create a bucket with multi-regional storage class:
gcloud storage buckets create --default-storage-class=MULTI_REGIONAL gs://${BUCKET}
The gcloud storage buckets create command is used to create a new Google Cloud Storage bucket. The --default-storage-class flag allows you to specify the storage class for the bucket, and the multi_regional storage class is designed for data that needs to be available in multiple regions (ideal for high availability and low-latency access).
Click Check my progress to verify the objective.
Create a bucket
Task 2. Upload objects to your bucket
- Run the following to copy the
endpointslambda object to your bucket:
gcloud storage cp -r endpointslambda gs://${BUCKET}
The gcloud storage cp -r command is used to copy files or directories to a Google Cloud Storage bucket.
In gcloud storage, multi-threaded and multi-processing parallel transfers are enabled automatically for high performance. The -r option allows recursion through directories.
Click Check my progress to verify the objective.
Upload objects to your bucket
Task 3. List objects
- To list objects in your bucket, execute the following command:
gcloud storage ls gs://${BUCKET}/*
This command lists all objects (files and directories) inside a specific bucket in Google Cloud Storage, including any nested objects.
Task 4. Sync changes with bucket
- Use the following commands to rename and delete some files:
mv endpointslambda/Apache2_0License.txt endpointslambda/old.txt
rm endpointslambda/aeflex-endpoints/app.yaml
- Now synchronize the local changes with the bucket:
gcloud storage rsync --delete-unmatched-destination-objects -r endpointslambda gs://${BUCKET}/endpointslambda
In this command, the --delete-unmatched-destination-objects flag deletes files from the target if they're missing in the source (in this case, it deletes app.yaml from the bucket). The -r option runs the command recursively across subdirectories.
- To verify that the bucket is now in sync with your local changes, list the files in the bucket again:
gcloud storage ls gs://${BUCKET}/*
Click Check my progress to verify the objective.
Sync changes with bucket
Task 5. Make objects public
- To allow public access to all files under the
endpointslambda folder in your bucket, execute the following command:
gcloud storage buckets add-iam-policy-binding gs://${BUCKET} --member=allUsers --role=roles/storage.objectViewer
The above command is used to grant public read permissions to Cloud Storage buckets and objects using IAM policy bindings. This makes all objects in the bucket publicly readable.
The --member=allUsers flag grants access to any user on the internet, while --role=roles/storage.objectViewer grants read permissions for objects in the bucket.
- To confirm files are viewable by the public, open the following link in a new incognito or private browser window, replacing
<your-bucket-name> with the full name of your bucket, not the environment variable:
http://storage.googleapis.com/<your-bucket-name>/endpointslambda/old.txt
This URL uses the Cloud Storage API link to view the object without authentication. Learn more about accessing public data from the Accessing public data documentation.
Task 6. Copy with different storage class
gcloud storage cp --storage-class=NEARLINE ghcn/ghcn_on_bq.ipynb gs://${BUCKET}
The gcloud storage cp command is used to copy files from one location to another, either within Cloud Storage or from a local file system to Cloud Storage and --storage-class flag specifies the storage class for the file being uploaded.
Click Check my progress to verify the objective.
Copy with different storage class
Task 7. Check storage classes
- Run the following to check the storage classes and view other detailed information about the objects in your bucket:
gcloud storage ls -L -r gs://${BUCKET} | more
- Press the SPACE key to continue viewing the rest of the command's output.
The output shows that the ghcn_on_bq.ipynb object has NEARLINE storage class while the other objects have MULTI_REGIONAL storage class.
Output:
gs://qwiklabs-xxx-xxxxxxxxxxxxxxxx-bucket/ghcn_on_bq.ipynb:
Creation time: Tue, 13 Aug 2019 20:19:27 GMT
Update time: Tue, 13 Aug 2019 20:19:27 GMT
Storage class: NEARLINE
Content-Length: 980176
Content-Type: application/octet-stream
...
gs://qwiklabs-xxx-xxxxxxxxxxxxxxxx-bucket/endpointslambda/:
gs://qwiklabs-xxx-xxxxxxxxxxxxxxxx-bucket/endpointslambda/README.md:
Creation time: Tue, 13 Aug 2019 20:03:29 GMT
Update time: Tue, 13 Aug 2019 20:15:43 GMT
Storage class: MULTI_REGIONAL
Content-Length: 452
Content-Type: text/markdown
...
- Press CTRL+C to return to the command line.
Congratulations
You have now learned how to perform operations on Cloud Storage buckets and objects!
Next steps / Learn more
For complete information about gcloud storage command-line options, see:
Google Cloud training and certification
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated on October 16, 2026
Lab Last Tested October 16, 2026
Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.