Open ajlake opened 3 years ago
It looks like you are using a bucket that has object versioning enabled.
To force delete an object in a bucket with versioning enabled, you will need to supply the generation number on deletion. We can add a new field called force_destroy that can perma-delete objects like that.
https://cloud.google.com/storage/docs/object-versioning#reference
In the meanwhile, use a bucket that has object versioning disabled.
This is a somewhat common request across several resource types, I'll file an upstream issue to see if this can get added at the core level instead of on a resource-by-resource basis. Assigning myself to do so.
@rileykarson does that mean this is an upstream terraform issue?
Ehh- I don't think this would go anywhere if filed. This is a request for a deletion_policy
field.
See https://googlecloudplatform.github.io/magic-modules/docs/best-practices/ for information on deletion_policy fields.
Community Note
Description
Introduce a
delete_on_destroy
field ongoogle_storage_bucket_object
. This is the same idea asdisable_on_destroy
for google_project_service.This is motivated by a terraform use case I'm dealing whereby a set of template files that change over time are rendered and uploaded to a GCS bucket. Old rendered files need to stay in the bucket until existing infrastructure that references them ages out, but I don't want to track the existence of these old files and templated values in source control. Having this flag would let me solve this nicely.
I'm currently working around this by using
null_resource
to shell out togsutil cp ...
.The work required to implement this seems straightforward, I'm happy to open a PR if it would be accepted. Thanks.
New or Affected Resource(s)
Potential Terraform Configuration
References
b/275717431