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

google_firestore_index non-blocking option #13422

Open rainshen49 opened 1 year ago

rainshen49 commented 1 year ago

Community Note

Description

A Firestore index can take a while to create. For a create index call, the API returns an operation, which the caller poll to wait. Currently, the Firebase CLI doesn't wait on this operation (just succeeds), and the UI surfaces (e.g. Cloud Console, Firebase Console) shows a non-blocking in-progress state in the UI. However, Terraform blocks on the index creation due to polling the returned operation, which makes terraform apply much slower (4 minutes per index for me on an empty database).

New or Affected Resource(s)

Potential Terraform Configuration

It's ok to CRUD Firestore documents as normal when the index is being built, so I can't see why we need to wait for the index to be fully built. This is probably why none of the other surfaces (CLI, Console) blocks anything on index creation. For backward compatibility, I suggest a skip_wait field to the Terraform resource that doesn't wait on the returned operation, and maybe make it the default behavior in a major release.

# 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.
resource "google_firestore_index" "my-index" {
  project = "my-project-name"
  ...

  skip_wait = true
}

References

skip_wait may also circumvent the problem experienced in #11316 because the permission "datastore.operations.get" is no longer necessary.

b/275100809

rainshen49 commented 1 year ago

Since I'm familiar with the codebase and API, I can also offer to work on this issue if folks are ok with the proposal.