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.36k stars 1.75k forks source link

Add TTL policy for Datastore #14806

Closed remko closed 1 year ago

remko commented 1 year ago

Community Note

Description

Datastore supports TTL policies on entities. I want to be able to set these TTL policies in terraform.

A similar feature for Firestore has recently been implemented.

New or Affected Resource(s)

A new resource such as google_datastore_ttl_policy

Potential Terraform Configuration

resource "google_datastore_ttl_policy" "default" {
  kind = "MyKind"
  timestamp_property = "expireAt"
}
# Propose what you think the configuration to take advantage of this feature should look like.
# We may not use it verbatim, but it's helpful in understanding your intent.

References

rileykarson commented 1 year ago

Hmm- there doesn't seem to be an admin-level REST API that makes sense for this. Is this configured under these methods? https://cloud.google.com/datastore/docs/reference/data/rest/v1/projects

lrnq commented 1 year ago

I submitted a feature request to pulumi-gcp at https://github.com/pulumi/pulumi-gcp/issues/1215, where it was mentioned that they are waiting on this particular issue to be resolved before including it.

In response to your query, @rileykarson, AFAICT, the feature isn't configured under any of the methods listed under that link.

It would be a great feature to include though, so hopefully we can figure something out. A newer issue https://github.com/hashicorp/terraform-provider-google/issues/15781 seem to request the feature as well.

rileykarson commented 1 year ago

Judging by the instructions in https://cloud.google.com/datastore/docs/ttl#gcloud and some manual testing, the resource to configure this for datastore is actually just https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/firestore_field! I manually created a project w/ the default database in datastore mode, and was able to use that resource to configure a TTL policy:

resource "google_firestore_field" "default" {
  project = "tf-test-4glueeyzzm" # datastore project
  database = "(default)"
  collection = "chatrooms"
  field = "my_ttl"

  ttl_config {}
github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.