Description
Cloud Storage Object Versioning keeps previous generations directly readable when a live object is overwritten or deleted without a generation number. Google recommends soft delete for recovery from accidental or malicious deletion.
Potential impact
If no recoverable generation or separate backup remains, the content may be lost. Keeping every generation indefinitely increases storage costs.
Remediation
Set versioning.enabled to true when you need readable history. Choose a recovery period, review soft delete and lifecycle rules, limit who can delete generations or the bucket, and test restoring an earlier generation.
Examples
Supply your bucket and project names and the path to your service account JSON file. These excerpts omit soft delete and lifecycle settings.
Before
- name: 버킷 생성
google.cloud.gcp_storage_bucket:
name: ansible-storage-module
project: test_project
auth_kind: serviceaccount
service_account_file: /tmp/auth.pem
state: present
versioning:
enabled: no
Disabling versioning stops retaining new noncurrent generations. Existing ones remain.
After
- name: 버킷 생성
google.cloud.gcp_storage_bucket:
name: ansible-storage-module
project: test_project
auth_kind: serviceaccount
service_account_file: /tmp/auth.pem
state: present
versioning:
enabled: yes
After enabling versioning, restore a retained generation by copying it to the original object name. Permanently deleted data remains unavailable.