Fix GCP Cloud Storage Object Hold Errors
When working with GCP Cloud Storage, you may encounter a configuration error that prevents your deployment from working. This guide explains the most common mistake with object hold and shows the exact fix.
A Common Mistake
Setting a retention hold on an object and then being unable to delete the object even after the retention policy expires, because the hold takes precedence.
The incorrect command:
gsutil retention hold set gs://my-bucket/compliance-record.pdf
Error output:
Setting retention hold on gs://my-bucket/compliance-record.pdf...
The object now has a retention hold. When the compliance period expires, the team tries to release the hold:
gsutil retention hold release gs://my-bucket/compliance-record.pdf
ERROR: 400 Cannot release retention hold: object has a temporary hold that was set by a different principal. Only the principal or project owners can release the hold.
The Correct Approach
The right way to configure object hold in GCP Cloud Storage:
gsutil retention hold release gs://my-bucket/compliance-record.pdf
Successful result:
Releasing retention hold on gs://my-bucket/compliance-record.pdf...
Hold released. The object can now be deleted or overwritten. The retention hold can only be released by the principal who set it or by project owners/editors.
How to Prevent This
Retention holds take precedence over retention policies. An object under retention hold cannot be deleted regardless of retention policy expiration. Track holds with gsutil ls -L gs://bucket and look for 'Retention: HOLD'. Only the principal who set the hold or project owners can release event-based holds. Test hold release with a non-production object first.
FAQ
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Secure your cloud with DodaTech.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro