Google Firestore Index

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

google_firestore_index (Terraform)

The Index in Firestore can be configured in Terraform with the resource name google_firestore_index. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

github-iconBlack-Artist-Database/blmsheet-terraform
resource "google_firestore_index" "composite-name-location-asc" {
    project           = var.project
    collection        = var.collection
    database          = "(default)"

    fields {
github-iconsreeram-boyapati/covid-contact-tracing
resource "google_firestore_index" "dev-consent-form" {
  project     = google_project.covidguard_lis_server.project_id

  collection = "dev_consent"

  fields {
github-iconfranckf-git/reference-go
resource "google_firestore_index" "trainings_user_time" {
  collection = "trainings"

  fields {
    field_path = "UserUuid"
    order      = "ASCENDING"
github-iconslaily/go-wild-workouts
resource "google_firestore_index" "trainings_user_time" {
  collection = "trainings"

  fields {
    field_path = "UserUuid"
    order      = "ASCENDING"
github-iconThreeDotsLabs/wild-workouts-go-ddd-example
resource "google_firestore_index" "trainings_user_time" {
  collection = "trainings"

  fields {
    field_path = "UserUuid"
    order      = "ASCENDING"

Parameters

  • collection required - string
    • The collection being indexed.

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

  • id optionalcomputed - string
  • name requiredcomputed - string
    • A server defined name for this index. Format: 'projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}'

  • project optionalcomputed - string
  • query_scope optional - string
    • The scope at which a query is run. Default value: "COLLECTION" Possible values: ["COLLECTION", "COLLECTION_GROUP"]

Explanation in Terraform Registry

Cloud Firestore indexes enable simple and complex queries against documents in a database. This resource manages composite indexes and not single field indexes. To get more information about Index, see:

  • API documentation
  • How-to Guides
    • Official Documentation

      Warning: This resource creates a Firestore Index 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 Index?

Google Firestore Index 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 Index?

For Terraform, the Black-Artist-Database/blmsheet-terraform, sreeram-boyapati/covid-contact-tracing and franckf-git/reference-go source code examples are useful. See the Terraform Example section for further details.

security-icon

Scan your IaC problem in 3 minutes for free

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