Username or Email Address
Google Cloud Storage is unified object storage provided by the Google Cloud Platform (GCP). It allows low cost and almost unlimited storage space with several features that make it a highly popular service. Understanding how to properly use and configure the different features you use can make a significant difference, both in terms of daily operations and overall cost. The Lifecycle management feature in Google Cloud storage makes this task easier. This feature is not limited to just Google Cloud storage, other Cloud storage solutions also offer similar lifecycle management services.
With lifecycle management services, rules can be added to automatically delete or move the data to another storage class. These rules can be added based on various factors such as age, creation date, storage class, versions, and state. These rules are useful when you want to control the way data live in the storage bucket. An example of this would be to automatically move the data to a cheaper storage class such as Nearline 60 days after creation and then move it to Coldline storage class after another 60 days. This way, you can not only reduce the cost but also the reduce time spent on managing the data. To manage the lifecycle rules, you can use the Google Cloud Console, Gsutil CLI, SDK or API.
In this article, we will explain How to Add Lifecycle Rule for a Cloud Storage Bucket to automate certain operations on your data and reduce the overall cost. We will explain the procedure by adding the two rules that will:
Note that we will be using the Google Cloud Console for adding the life cycle rules.
As the lifecycle rules are applied to a bucket, so the first step would be to create a bucket. If you have already created a bucket, then you can proceed with the following procedure:
In the following procedure, we will explain how to add a rule that automatically deletes data if the specified conditions are met. As an example, we will create a rule by which any object older than 10 days will be automatically deleted.
1. Open the following link to navigate to the GCP Browser.
2. Select the project where you have created the bucket by using the drop-down arrow at the top bar.
3. In the Storage browser window, you will see different columns against each bucket. Click None under the Lifecycle rules column for your desired bucket as follows:
4. Next, in the following window, click the Add rule button to add the lifecycle rule. Note that the rule you add will be applied to all objects in a bucket.
5. Select the conditions for the object. Action will be triggered if the specified conditions are met. You can choose from the following conditions set:
In our example, we have specified 10 days for age. Once you have selected the required condition, click CONTINUE button.
6. Next, select the required action to be taken if the above conditions are met. As we are going to set a rule to automatically delete the data if the conditions are met. So choose the Delete option and click Continue.
Then click the Save button in order to save the rule.
In the following procedure, we will see how to add a rule that automatically changes the storage class if the specified conditions are met. Changing the storage class of older and less commonly accessed data can greatly reduce the storage costs. As an example, we will create a rule by which any object older than 10 days residing in Standard storage class will be automatically moved to Nearline storage class.
3. In the Storage browser window, you will see different columns against each bucket. Click the None under the Lifecycle rules column for your desired bucket. Note that, if you have already created a rule (like in our case), you will see it listed under the Lifecycle rules instead of None as shown below:
4. Now in the following view, click the Add rule button in order to add the lifecycle rule. Note that the added rule will be applied to all objects in a bucket.
5. Select the conditions for the object. Action will be triggered if the specified conditions are met. You can choose from the different conditions set (explained in the previous section).
6. Next, select the required action to be taken if the above conditions are met. As we are going to set a rule to automatically change the storage class if the specified conditions are met. So choose either of the following options and click Continue.
Now click the Save button in order to save the rule.
That is all there is to it! In this article, we have explained how to add lifecycle rules for a Cloud Storage Bucket. These lifecycle rules can help you in automating certain operations on the data as well as reducing the cost of data storage in Google Cloud.
Software by Karim Buzdar