Terraform-provider-google: Allow configuring Firestore on a project with Terraform

Created on 19 May 2019  ·  14Comments  ·  Source: hashicorp/terraform-provider-google


Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

Adding the ability to manage Cloud Firestore resources like collections and documents. Looks like indices already exist.

New or Affected Resource(s)

https://github.com/terraform-providers/terraform-provider-google/issues/3305 added support for indices, but I'd love the ability to create collections and manage them through Terraform as well.

Potential Terraform Configuration

resource "google_firestore_collection" "my-collection" {
  project    = "my-project-name"

  name = "my-collection-name"
}
resource "google_firestore_document" "my-document" {
  project    = "my-project-name"
  collection = "my-collection-name"

  name = "my-document-name"

  fields {
    name = "foo"
    type = "string"
    value = "bar"
  }
}

References

https://cloud.google.com/firestore/docs/concepts/index-overview
https://github.com/terraform-providers/terraform-provider-google/issues/3305
https://github.com/GoogleCloudPlatform/magic-modules/issues/1578

enhancement new-resource priorit2 upstream

Most helpful comment

Ah, yep- project-level enablement of Firestore is something I'd like to expose, but that's not possible in the API today. I'm tracking a bug internally though, and that will be added when it's possible.

All 14 comments

Hey @plebasaurus!

I don't think we can publish a google_firestore_collection resource, collections are created implicitly when you add a document to a collection and don't have a separate API.

We could add a google_firestore_document resource, but I'm curious what the usecase is for managing Firestore entries with Terraform. To me, they feel like something that should be managed by application-level code more than as infrastructure, so I'm curious if you (or anyone else reading this!) have different expectations for usage.

I think a resource that would add a Firestore database in a specific mode and datastore location to a project would make sense. As @rileykarson mentioned collections and documents are created implicitly (collections will be created automatically when you add a document and didn't specified a collection) so there is no further relation to infrastructure for me either.

Ah, yep- project-level enablement of Firestore is something I'd like to expose, but that's not possible in the API today. I'm tracking a bug internally though, and that will be added when it's possible.

Hey @rileykarson, thanks for the response.

I guess I totally missed that creation is implicit for collections but here's what I was thinking anyway:

For google_firestore_collections, I'd like to be able to create a collection for each environment. I guess I'm considering any datastore associated with my application as part of the infrastructure all of which I'd like to manage in Terraform. Goal being the ability to re-create the full environment in a new/separate project.

I care less about documents but I guess an example use-case for google_firestore_document would help: lets say I'm managing user information in firestore, and want to add a default "test" user for integration tests on unique environments.

Ultimately, I agree with @racoon63's suggestion

That makes sense- I created #3950 for Firestore documents to split out the use case of initializing Firestore vs document creation, I'll rename this issue to cover initialization.

Ah, yep- project-level enablement of Firestore is something I'd like to expose, but that's not possible in the API today. I'm tracking a bug internally though, and that will be added when it's possible.

Still not possible or we can try to move this issue further?

Still not possible. I"m watching the internal issue for support getting added, but there's been no progress.

@rileykarson any update on that? it's been a few months...

Automated backups fits to this issue?

Firestore collection backup docs

@ndeitch: I'd suggest filing a new issue for that feature.

@jaceq: Still nothing, sorry!

Any update on this? This prevents automatic project creation with datastore, does't it?

There is alpha gcloud support for this now, but there is a bug:

When you create the app engine application from a service account, creating the firestore instance fails.

https://issuetracker.google.com/issues/148567895 (the suggestion to downgrade gcloud is wrong)

Hi, it looks like the issue that was causing issues for service accounts is now fixed, which makes project level enabling of Firestore possible.

https://issuetracker.google.com/issues/148567895

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings