Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Firestore Document resource #3950

Comments

@rileykarson
Copy link
Collaborator

rileykarson commented Jul 1, 2019

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

Add the ability to create a Firestore document using Terraform. This is also the best way to expose the creation of collections, which are created implicitly when a document is created.

New or Affected Resource(s)

  • google_firestore_document

Potential Terraform Configuration

resource "google_firestore_document" "admin" {
  collection = "users"
  name = "admin"
  fields = {
    username = "admin"
    password = "hunter2"
  }
}

References

@jakebiesinger-onduo
Copy link

In our use case, we use firestore for lightweight read-only application configuration, which I'd like to have checked in as code. Terraform 0.12's lets me specify that config natively, and I'd like to publish it to firestore.

As a workaround, you can do this via cmdline, with all the usual caveats for doing so:

locals {
  customers = [
    { 
      name = "customer1"
      some = "value"
      a-number = 123
    }
  ]
}
resource "null_resource" "deploy-customer-config" {
  count = length(local.customers)

  triggers = {
    source = jsonencode(local.customers[count.index])
  }

  provisioner "local-exec" {
    command = <<EOF
firebase --project ${local.project} database:set --confirm /client-config/${local.customers[count.index].name} --data '${jsonencode(local.customers[count.index])}'
EOF
  }
}

@adarobin
Copy link

The use case I have for this is we currently use Cloud Datastore to store metadata about projects we have created for our internal customers. We're trying to rebuild our existing provisioning process using Terraform, and this would make storing that metadata much less painful.

@thomas-stockx
Copy link

thomas-stockx commented Aug 12, 2020

In our use case, we use firestore for lightweight read-only application configuration, which I'd like to have checked in as code. Terraform 0.12's lets me specify that config natively, and I'd like to publish it to firestore.

As a workaround, you can do this via cmdline, with all the usual caveats for doing so:

locals {
  customers = [
    { 
      name = "customer1"
      some = "value"
      a-number = 123
    }
  ]
}
resource "null_resource" "deploy-customer-config" {
  count = length(local.customers)

  triggers = {
    source = jsonencode(local.customers[count.index])
  }

  provisioner "local-exec" {
    command = <<EOF
firebase --project ${local.project} database:set --confirm /client-config/${local.customers[count.index].name} --data '${jsonencode(local.customers[count.index])}'
EOF
  }
}

The command line example here uses Realtime Database instead of Firestore and is therefore not really a workaround for having no Firestore Document resource.

Our use-case is the same however, storing config data in Firestore for some of our more lightweight applications, as well as an admin list for some Firestore security rules.

EDIT: For now I'm working around this by first deploying a Cloud Function which takes json as input and puts it into Firestore as data, which I can then pass a curl request to in a local-exec. Definitely not the cleanest solution, but it works.

modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Sep 11, 2020
* Add guide on deleted principals

* PR feedback, website link

Signed-off-by: Modular Magician <[email protected]>
modular-magician added a commit that referenced this issue Sep 11, 2020
* Add guide on deleted principals

* PR feedback, website link

Signed-off-by: Modular Magician <[email protected]>
slevenick pushed a commit that referenced this issue Sep 11, 2020
* Add guide on deleted principals

* PR feedback, website link

Signed-off-by: Modular Magician <[email protected]>
@ScottSuarez ScottSuarez self-assigned this Oct 26, 2020
@ScottSuarez ScottSuarez modified the milestones: Near-Term Goals, Sprint 25 Nov 9, 2020
@rileykarson rileykarson modified the milestones: Sprint 25, Sprint 26 Nov 23, 2020
@ghost
Copy link

ghost commented Jan 3, 2021

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!

@ghost ghost locked as resolved and limited conversation to collaborators Jan 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.