google_firestore_field

Represents a single field in the database. Fields are grouped by their "Collection Group", which represent all collections in the database with the same id.

To get more information about Field, see:

Example Usage - Firestore Field Basic

resource "google_firestore_database" "database" {
  project     = "my-project-name"
  name        = "database-id"
  location_id = "nam5"
  type        = "FIRESTORE_NATIVE"

  delete_protection_state = "DELETE_PROTECTION_ENABLED"
  deletion_policy         = "DELETE"
}

resource "google_firestore_field" "basic" {
  project    = "my-project-name"
  database   = google_firestore_database.database.name
  collection = "chatrooms_%{random_suffix}"
  field      = "basic"

  index_config {
    indexes {
        order = "ASCENDING"
        query_scope = "COLLECTION_GROUP"
    }
    indexes {
        array_config = "CONTAINS"
    }
  }
}

Example Usage - Firestore Field Timestamp

resource "google_firestore_database" "database" {
  project     = "my-project-name"
  name        = "database-id"
  location_id = "nam5"
  type        = "FIRESTORE_NATIVE"

  delete_protection_state = "DELETE_PROTECTION_ENABLED"
  deletion_policy         = "DELETE"
}

resource "google_firestore_field" "timestamp" {
  project    = "my-project-name"
  database   = google_firestore_database.database.name
  collection = "chatrooms"
  field      = "timestamp"

  # enables a TTL policy for the document based on the value of entries with this field
  ttl_config {}

  // Disable all single field indexes for the timestamp property.
  index_config {}
}

Example Usage - Firestore Field Match Override

resource "google_firestore_database" "database" {
  project     = "my-project-name"
  name        = "database-id"
  location_id = "nam5"
  type        = "FIRESTORE_NATIVE"

  delete_protection_state = "DELETE_PROTECTION_ENABLED"
  deletion_policy         = "DELETE"
}

resource "google_firestore_field" "match_override" {
  project    = "my-project-name"
  database   = google_firestore_database.database.name
  collection = "chatrooms_%{random_suffix}"
  field      = "field_with_same_configuration_as_ancestor"

  index_config {
    indexes {
        order = "ASCENDING"
    }
    indexes {
        order = "DESCENDING"
    }
    indexes {
        array_config = "CONTAINS"
    }
  }
}

Argument Reference

The following arguments are supported:


The index_config block supports:

The indexes block supports:

The ttl_config block supports:

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

Timeouts

This resource provides the following Timeouts configuration options:

Import

Field can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import Field using one of the formats above. For example:

import {
  id = "{{name}}"
  to = google_firestore_field.default
}

When using the terraform import command, Field can be imported using one of the formats above. For example:

$ terraform import google_firestore_field.default {{name}}

User Project Overrides

This resource supports User Project Overrides.