Search code examples
google-cloud-platformgoogle-cloud-storage

GCP GCS (Google Cloud Storage) object-level retention policy


Is it possible to define retention policy for individual file in a GCS bucket?

For example, if the bucket is set to have minimum retention of 1 year:

  • Is it possible for "file A" retention policy set to 2 years and "file B" set to 5 years?
  • If yes, is it done using prefixes (like AWS S3)? Can I immediately set to x number of year for the file?

Solution

  • GCS allows for object holds on individual objects. These are metatdata flags set on the object that force retention (no deletes or modifications) regardless of the bucket policy, and must be manually removed in the future.

    There are 2 types:

    • Event-based holds will start the retention countdown clock once the hold is removed.
    • Temporary holds have no effect on the retention countdown so it starts when the object is first created.