Home Cloud Configure Lifecycle Rules in Google Cloud Storage Buckets

Configure Lifecycle Rules in Google Cloud Storage Buckets

by Noyal S
Storage buckets Google

Google Cloud Storage is an object storage service that provides multiple features such as

  1. High availability 
  2. Built-in server-side encryption 
  3. Different storage classes 
  4. Lifecycle management

Saving an object in a cloud storage bucket is usually inexpensive depending on the storage class we use. The Google Cloud Storage pricing per GB is low but when it comes to a large volume of data or multiple APIs operations, it will increase the cost quickly. Here, the Google Cloud Storage Lifecycle Management Rules provide you with a solution to deal with different and unpredictable data. Lifecycle rules can be set up to automatically change the storage classes or to automatically delete unnecessary data for cost optimization. 

Create a Google Cloud Storage bucket 

  1. Login to your GCP console 
  1. Go to the storage section and start the process by clicking “Create Bucket”
  1. Provide the required information to complete the bucket creation process. 

GCP Storage classes

The storage classes in GCP allow the customers to have control over the type of availability they need from their data. The storage class can be configured either for individual objects or for the entire bucket. Familiarizing the storage classes is important for the cost-efficient usage of Google cloud storage. 

The three different storage classes in the object-based Google Storage service are  

  • Standard: The standard storage class is well suited for frequently accessed data and for data stored for a short period of time. 
  • Nearline: The nearline storage class is recommended for infrequently accessed data. This class is ideal for data that only needs to be accessed once a month or less like data backups, archiving, and media content at a reduced cost compared to standard storage.
  • Coldline: The Codeline storage class is best for data that we plan to access once a year or less. The storage cost is very low – $0.007 per GB/month compared to other storage classes. But note that, the cost of access per operation is higher. 

Once the bucket is created and files are uploaded we can proceed with the Lifecycle rule configuration to manage them. 

Steps to Configure a Lifecycle rule to automatically delete data.

  1. Login to the GCP console 
  1. Navigate to “Cloud Storage” and select “Buckets”
  1. Click on the bucket you want to set the lifecycle policy.
  1. And navigate to the option LIFECYCLE as shown in the screenshot below.
  1. Click on the button “ADD A RULE” to create a rule. 
  1. Now we can select conditions that the object must meet to trigger a specific action. 
  1. Select an action: Delete Objects
  1. Set Conditions: Age 

Enter the number in the Age field and click on the create button.

For this case, I’ve added a rule to delete any objects in the bucket that is older than 30 days.

The rule will be activated immediately after saving the changes. 

How to Configure a Lifecycle rule to automatically change the storage classes

In this scenario, we are configuring a lifecycle rule to automatically change the storage class (Standard class to Coldline class) for data inside the bucket that was created before a certain date for cost optimization. 

  1. Login to the GCP console 
  1. Navigate to “Cloud Storage” and select “Buckets”
  1. Click on the bucket you want to set the lifecycle policy.
  1. And navigate to the option LIFECYCLE and click on the button “ADD A RULE”
  1. Now select an action: 


Here we are using the option “Set storage class to Codeline” and click on the continue button.

  1. Select object conditions: 

Here we can select the conditions to trigger the storage class change. 

For this scenario, we are using the object creation date to automatically transfer the objects which are created on or before February 28, 2023, to the Standard to Coldline storage class.

  1. The rule will be activated once you click the create button and will be listed under the lifecycle option along with the previously created rules. 

Leave a Comment