Google Cloud: Creating Lifecycle Policies for Cloud Storage Bucket

Share At:

What is Lifecycle Policy?

  • It is used to create rules like setting a Time to Live (TTL) for objects, or “downgrading” storage classes of objects to help save money.
  • You can add a lifecycle management configuration to a bucket. You will have to add certain conditions so once an object meets the criteria of any of the rules, Cloud Storage automatically performs a specified action on the object.

Here are some example use cases:

  • Adding a rule to downgrade the storage class for the objects older than 180 days to Coldline Storage.
  • Adding a rule for Deletion of objects created before Dec 01, 2020.

There are two types of actions that can be specified in a lifecycle rule. i.e. Delete or SetStorageClass

  • Delete: It deletes an object when the object meets the conditions specified in the lifecycle policy.
  • SetStorageClass: It changes the storage class of an object when a certain object meets the specified conditions in the lifecycle policy.

Note: Updates to your lifecycle configuration rules might take up to 24 hours to take effect which means rules may still perform actions based on the old setup for up to 24 hours.

Lab Details:

  1. This lab walks you through Lifecycle Policy for Cloud Storage Bucket.
  2. You will be adding a rule to delete an Object from your bucket after a certain time.

Lab Tasks:

  1. Login into GCP Console.
  2. Creating a bucket.
  3. Uploading an object into your bucket.
  4. Adding permissions for your bucket.
  5. Adding lifecycle policy.

Creating a Cloud Storage Bucket and adding lifecycle policy:

  1. Click on the hamburger icon on the top left corner
  2. Click on the Cloud Storage tab.

3. Click on “create bucket”.

4. Enter the name for your bucket as “whizlabs-storage-lab”. The name should be globally unique name. Click Continue.

5. Choose the location as US and type as multi-region to get high availability. Click Continue.

6. Choose storage class as Standard.

7. Choose access control as “Uniform” to get the same access for all the objects in the bucket.

8. Click on create to finally create your bucket.

9. Choose upload files in your bucket as shown

10. Once you choose your file and upload it, it will appear like this. Object names can be different.

11. You have to add permission so that only authenticated users can see the object.

12. Click on add.

13Enter member as allAuthenticatedUsers and Select role as Storage object viewer in Cloud Storage.

14. Click on Save to continue.

15. Click on allow public access.

16. You can see your uploaded object.

17. You can use this public URL to load your object.

18. Once you are inside your bucket, Click on the “Lifecycle tab”.

19. Click on “add a rule” to add a lifecycle policy.

20. Select action to delete an object once it satisfies a certain condition.

21. Click on continue to proceed further.

22. Opt as “Age” in the condition and mention 30 days, which means after 30 days objects will be deleted automatically.

23. Click on create to finally create the rule.

Completion and Conclusion:

  1. In this lab, you have created a Cloud Storage Bucket and uploaded an Object into the bucket.
  2. You have added a rule to delete an object after 30days of upload.

Happy Learning !!!

Share At:
0 0 votes
Article Rating
Notify of
Oldest Most Voted
Inline Feedbacks
View all comments
binance doporučení
12 days ago

Your article helped me a lot, is there any more related content? Thanks!

creación de cuenta en Binance

Thanks for sharing. I read many of your blog posts, cool, your blog is very good.

Mag-sign Up upang makakuha ng 100 USDT

Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

bitcoin indonesia vip
2 months ago

Reading your article has greatly helped me, and I agree with you. But I still have some questions. Can you help me? I will pay attention to your answer. thank you.

Back To Top

Contact Us