Home / Google Cloud / Cloud Storage Object life cycle management

Cloud Storage Object life cycle management

Last updated on May 11th, 2023

Estimated reading time: 4 minutes

To support Time to Live (TTL) for objects, retaining noncurrent versions of objects, or “downgrading” storage classes of objects to help manage costs, Cloud Storage offers the Object Life cycle Management feature.

How to Configure Set Storage class Rule for object life cycle

If you are new to Google cloud platform refer article to create tier account here Google cloud free tier account – Full Stack Tutorials Hub . Free Tier account provides 300 $ credit to learn and explore google cloud services.

Lifecycle rules let you apply actions to a bucket’s objects when certain conditions are met. Each lifecycle management configuration contains a set of rules. Each rule contains one action and one or more conditions.

A lifecycle rule specifies exactly one of the following actions:

  • Delete: The Delete action deletes an object when the object meets all conditions specified in the lifecycle rule.
  • Set Storage Class: Theย SetStorageClassย action changes theย storage of an object and updates the object’sย modification time when the object meets all conditions specified in the lifecycle rule.

An object has to match all of the conditions specified in a rule for the action in the rule to be taken.

If multiple rules have their conditions satisfied simultaneously for a single object, Cloud Storage performs the action associated with only one of the rules, based on the following considerations:

The Delete action takes precedence over any SetStorageClass action.

The SetStorageClass action that switches the object to the storage class with the lowest pricing takes precedence. For example, if you have one rule that changes the object’s class to Nearline storage and another rule that changes the object’s class to Coldline storage, but both rules use the exact same condition, the object’s class always changes to Coldline storage when the condition is met.

Changes to a bucket’s lifecycle configuration can take up to 24 hours to go into effect, and Object Lifecycle Management might still perform actions based on the old configuration during this time. For example, if you change an age condition from 10 days to 20 days, an object that is 11 days old could be deleted by Object Lifecycle Management up to 24 hours later, due to the criteria of the old configuration.

If you are new to Google cloud storage refer article to create storage bucket and add data here How to store data in Google Cloud Storage – Full Stack Tutorials Hub .

SetStorageClass supports the following storage class transitions:

Original storage classNew storage class
Standard storage, Multi-Regional storage, or Regional storageNearline storage
Coldline storage
Archive storage
Nearline storageColdline storage
Archive storage
Coldline storageArchive storage

Open storage bucket, navigate to Lifecycle tab and click on Add Rule to configure new Rule. Select action “Set storage class Nearline.”.

set storage class rule

Configure condition and set condition for age to 30. Click on create rule. This rule will apply the action to current and future objects when objects ages > 30 days in this bucket.

Object Age

How to Configure Delete Rule for object life cycle

Open storage bucket, navigate to Lifecycle tab and click on Add Rule to configure new Rule. Select action “Delete Object”.

Delete object rule

Configure condition and set created before date to 31 Dec 2022. Click on create rule. This rule will apply the action to current and future objects. All objects that were uploaded to this bucket before 31 Dec 2022 would be deleted.

Delete condition

Scroll to Top