hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.25k stars 1.7k forks source link

Allow google_storage_bucket_object Content-Type to be empty #17058

Open kaiburjack opened 5 months ago

kaiburjack commented 5 months ago

Community Note

Description

Currently, when creating a google_storage_bucket_object, the Content-Type on the GCS object will be "application/octet-stream" or "text/plain; charset=utf-8" by default if not specified otherwise as per the documentation. However, it is currently not possible to completely omit setting the Content-Type such that this metadata field is empty on the resulting GCS object. Setting content_type = "" results in the same behaviour as if the content_type was not set at all. And setting it to a non-empty spaces string like content_type = " " results in a 400 HTTP error from the Google API saying that the provided content_type differs from the one specified using the upload.

Why would we like to specify an empty content type?

The reason why we would like to set the Content-Type metadata field completely empty on the resulting GCS object is, because some clients of ours that create GCS objects (without Terraform) won't set the Content-Type field themselves, leading to empty Content-Type metadata on the respective GCS objects. In that case, we built a way to infer the correct content type ourselves when delivering the GCS object via another HTTP server (gcs proxy). In order to test that this works correctly, we need to provide test data in a test bucket, and we would like to do this via Terraform. And for this to work, we need a way to create GCS objects (via Terraform) with the Content-Type metadata field to be empty.

New or Affected Resource(s)

Potential Terraform Configuration

Maybe that content_type = null will be treated differently to setting content_type = "".

References

None.

b/321924149

melinath commented 5 months ago

Note from triage: The Terraform plugin SDK generally doesn't distinguish between empty values and null values. Although it is possible to work around this somewhat, it would be a breaking change for users, who may currently rely on the behavior of "".

Probably the best path forward at the moment would be to add a boolean field to control the behavior of the content_type field, similar to https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/privateca_ca_pool#zero_max_issuer_path_length

kaiburjack commented 5 months ago

Thanks for triaging and getting back to this so quickly. I am fine with either solution/way. :)