Working with Google Cloud Storage from the Command Line
The gsutil
component of the Google Cloud Software Developer Kit (SDK) provides a command line interface (CLI) to working with Google Cloud Storage. In contrast to using the Cloud Console to work with Cloud Storage, the CLI is ideal for automating workflows. As you will see in this lab, gsutil
is capable of doing everything that you can do in the Console and much more.
In this lab, you will use an instance that comes with gsutil
pre-installed and ready to use. You will first learn how to create buckets and different methods for transferring files to Google Cloud Storage using gsutil
. Lastly, you will explore Cloud Storage object versioning and see how to configure Object Lifecycle Management to control costs when versioning is enabled on a bucket.
Lab Objectives
Upon completion of this lab you will be able to:
- Use and explain what Google Cloud Shell is
- Use
gsutil
to perform a variety of Cloud Storage operations including creating buckets, transferring files, and performing diagnostic tests - Change the storage class of individual objects in a Cloud Storage bucket with
gsutil
- Enable object versioning on buckets with
gsutil
- Configure Object Lifecycle Management to control additional costs associated with object versioning
Lab Prerequisites
You should be familiar with:
- Working at the command line in Linux
- Basic Google Cloud Storage Concepts
The following labs are recommended for satisfying the prerequisites:
Updates
Dec. 21st, 2020 - Updated lab to use a GCE instance rather than Cloud Shell to avoid availability issues
Sept. 9th, 2019 - Lab content updated to reflect the latest Google Cloud Storage and gsutil
experience
July 3rd, 2019 - Added a custom validation lab step
Environment before
Environment after
Logan has been involved in software development and research since 2007 and has been in the cloud since 2012. He is an AWS Certified DevOps Engineer - Professional, AWS Certified Solutions Architect - Professional, Microsoft Certified Azure Solutions Architect Expert, MCSE: Cloud Platform and Infrastructure, Google Cloud Certified Associate Cloud Engineer, Certified Kubernetes Security Specialist (CKS), Certified Kubernetes Administrator (CKA), Certified Kubernetes Application Developer (CKAD), and Certified OpenStack Administrator (COA). He earned his Ph.D. studying design automation and enjoys all things tech.