Description
Cloud Storage Object Versioning keeps previous generations readable when an object is overwritten or deleted without a generation number. Soft delete or a separate backup may also provide a recovery path.
Potential impact
If no recoverable copy remains, an overwrite or deletion may be permanent. Separate controls govern deletion of the bucket or a specific generation.
Remediation
- Set
versioning { enabled = true }if you need ongoing access to earlier generations. Test recovery by copying one to the original object name. - Review soft delete and lifecycle retention, including storage costs. Limit deletion permissions and configure any required immutability controls separately.
Examples
Choose an available bucket name for your environment. Both examples use the EU location.
Before
hcl
resource "google_storage_bucket" "example" {
name = "foo"
location = "EU"
versioning {
enabled = false
}
}
After
hcl
resource "google_storage_bucket" "example" {
name = "foo"
location = "EU"
versioning {
enabled = true
}
}
Explanation:
- Before: Disabling versioning stops retaining new noncurrent generations. Check the other recovery options on this bucket.
- After: Subsequent changes retain earlier generations. Enabling versioning cannot restore data already permanently deleted.