Setting Cloud Storage Lifecycle Rules

30 minutes
  • 5 Learning Objectives

About this Hands-on Lab

While saving an object in a Cloud Storage bucket is relatively inexpensive, there is, nonetheless, a cost. The cost varies depending on the storage class selected. Certain objects are required to be more available at first, requiring the storage class with the highest availability — and cost. Such objects may eventually be relegated to less available and less expensive storage classes and, even, be deleted. Management of these objects over time can be handled automatically by establishing and implementing lifecycle rules. In this hands-on lab, we’ll set a variety of lifecycle rules for Google Cloud Storage buckets both from the console and the command line.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create a Cloud Storage bucket.
  1. From the Google Cloud console main navigation, choose Cloud Storage.
  2. Click Create bucket.
  3. Name the bucket uniquely and click Continue
  4. In the Location Type section, select Region and click Continue.
  5. Click Create.
Define first lifecycle rule.
  1. From the Cloud Storage browser page, click None in the Lifecycle column for the bucket just created.
  2. Click Add rule.
  3. Under Select object conditions, set the following:
    • Age: 180
    • Storage class: Regional, Standard
  4. Click Continue.
  5. Under Select action, choose Set to Nearline.
  6. Click Continue.
  7. Click Save.
Define second lifecycle rule.
  1. From the Cloud Storage browser page, click Enabled in the Lifecycle column.
  2. Click Add rule.
  3. Under Select object conditions, set the following:
    • Age: 365
    • Storage class: Nearline
  4. Click Continue.
  5. Under Select action, choose Set to Coldline.
  6. Click Continue.
  7. Click Save.
From command line, get lifecycle rules.
  1. Click Activate Cloud Shell.

  2. In the Cloud Shell, enter the following code:

    gsutil lifecycle get gs://[BUCKETNAME]
  3. Review output.

Set lifecycle rule with JSON file.
  1. Clone a repo and change to the lab’s directory:

    git clone https://github.com/linuxacademy/content-gc-essentials
    cd content-gc-essentials/cloud-storage-lifecycle-lab
  2. Review file in editor.

  3. In the Cloud Shell, enter the following code:

    gsutil lifecycle set delete-after-two-years.json gs://[BUCKET_NAME]
  4. Confirm the lifecycle rule has been added in the console.

Additional Resources

Your entire company is looking for ways to lower expenses, and you’ve been asked to set up a series of Cloud Storage lifecycle rules for a particular bucket that will move the objects within it from a Regional storage class to Nearline after six months, then to Coldline after a year, and finally to delete the objects after two years. You decide to use both the console and the command line to achieve these goals.

You’ll need to accomplish the following steps to complete your task:

  1. Create a Cloud Storage bucket.
  2. Establish lifecycle rules in the console.
    • After 180 days, set to Nearline.
    • After 365 days, set to Coldline.
  3. From command line, get lifecycle rules.
  4. Set lifecycle rule from command line using JSON file.
What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!
Thanks for reaching out!

You’ll hear from us shortly. In the meantime, why not check out what our customers have to say about ACG?