Google Firestore Document

This page shows how to write Terraform for Firestore Document and write them securely.

google_firestore_document (Terraform)

The Document in Firestore can be configured in Terraform with the resource name google_firestore_document. The following sections describe 4 examples of how to use the resource and its parameters.

Example Usage from GitHub
resource "google_firestore_document" "store_1" {
  count = var.generate-sample-data ? 1 : 0
  project = var.gcp_project
  collection = "store"
  document_id = "b13ee4d6-d1b2-403e-bd3d-3779760fa2a9"
  fields      = <<EOT
resource "google_firestore_document" "config" {
  project     = var.project
  depends_on = [time_sleep.wait_30_seconds]
  collection  = "tontocloudwalk"
  document_id = "config"
  fields      = jsonencode(
resource "google_firestore_document" "mydoc" {
  project     = var.config["project"]
  collection  = "list"
  document_id = "users"
  fields      = file("list.json")
resource "google_firestore_document" "mydoc" {
  project     = var.config["project"]
  collection  = "list"
  document_id = "users"
  fields      = file("list.json")


  • collection required - string
    • The collection ID, relative to database. For example: chatrooms or chatrooms/my-document/private-messages.

  • create_time requiredcomputed - string
    • Creation timestamp in RFC3339 format.

  • database optional - string
    • The Firestore database id. Defaults to '"(default)"'.

  • document_id required - string
    • The client-assigned document ID to use for this document during creation.

  • fields required - string
    • The document's fields formated as a json string.

  • id optionalcomputed - string
  • name requiredcomputed - string
    • A server defined name for this index. Format: 'projects/{{project_id}}/databases/{{database_id}}/documents/{{path}}/{{document_id}}'

  • path requiredcomputed - string
    • A relative path to the collection this document exists within

  • project optionalcomputed - string
  • update_time requiredcomputed - string
    • Last update timestamp in RFC3339 format.

Explanation in Terraform Registry

In Cloud Firestore, the unit of storage is the document. A document is a lightweight record that contains fields, which map to values. Each document is identified by a name. To get more information about Document, see:

  • API documentation
  • How-to Guides
    • Official Documentation

      Warning: This resource creates a Firestore Document on a project that already has Firestore enabled. If you haven't already enabled it, you can create a google_app_engine_application resource with database_type set to "CLOUD_FIRESTORE" to do so. Your Firestore location will be the same as the App Engine location specified.

Frequently asked questions

What is Google Firestore Document?

Google Firestore Document is a resource for Firestore of Google Cloud Platform. Settings can be wrote in Terraform.

Where can I find the example code for the Google Firestore Document?

For Terraform, the billietl/price-comparator, LeoMarangoni/ and alisahp/gcp source code examples are useful. See the Terraform Example section for further details.


Scan your IaC problem in 3 minutes for free

You can keep your IaC security for free. No credit card required.