When object versioning for Google Cloud Storage (GCS) buckets is enabled, different versions of an object are stored in the bucket, preventing accidental deletion. A specific version can always be deleted when the generation number of an object version is specified in the request.
Object versioning cannot be enabled on a bucket with a retention policy. A retention policy ensures that an object is retained for a specific period of time even if a request is made to delete or replace it. Thus, a retention policy locks the single current version of an object in the bucket, which differs from object versioning where different versions of an object are retained.
There is a risk if you answered yes to this question.
It’s recommended to enable GCS bucket versioning and thus to have the possibility to retrieve and restore different versions of an object.
Versioning is disabled by default:
resource "google_storage_bucket" "example" { # Sensitive
name = "example"
location = "US"
}
Versioning is enabled:
resource "google_storage_bucket" "example" {
name = "example"
location = "US"
versioning {
enabled = "true"
}
}