Skip to content

Latest commit

 

History

History
173 lines (156 loc) · 6.5 KB

File metadata and controls

173 lines (156 loc) · 6.5 KB

Firestore

This module allows to crete a firestore datatabase, fields, indexes and documents.

Examples

New database

module "firestore" {
  source     = "./fabric/modules/firestore"
  project_id = "my-project"
  database = {
    name        = "my-database"
    location_id = "nam5"
    type        = "FIRESTORE_NATIVE"
  }
}
# tftest modules=1 resources=1 inventory=new-database.yaml

New database with weekly backup

module "firestore" {
  source     = "./fabric/modules/firestore"
  project_id = "my-project"
  database = {
    name        = "my-database"
    location_id = "nam5"
    type        = "FIRESTORE_NATIVE"
  }
  backup_schedule = {
    retention         = "86400s"
    weekly_recurrence = "MONDAY"
  }
}
# tftest modules=1 resources=2 inventory=new-database-with-weekly-backup.yaml

New database with document

module "firestore" {
  source     = "./fabric/modules/firestore"
  project_id = "my-project"
  database = {
    name        = "my-database"
    location_id = "nam5"
    type        = "FIRESTORE_NATIVE"
  }
  documents = {
    my-doc-1 = {
      collection  = "my-coll"
      document_id = "d3db1c14-e56d-4597-af1c-f95c2d2290c1"
      fields = {
        field1 = "value1"
        field2 = "value2"
      }
    }
  }
}
# tftest modules=1 resources=2 inventory=new-database-with-document.yaml

Existing database with document

module "firestore" {
  source     = "./fabric/modules/firestore"
  project_id = "my-project"
  database = {
    name = "my-database"
  }
  database_create = false
  documents = {
    my-doc-1 = {
      collection  = "my-coll"
      document_id = "d3db1c14-e56d-4597-af1c-f95c2d2290c1"
      fields = {
        field1 = "value1"
        field2 = "value2"
      }
    }
  }
}
# tftest modules=1 resources=1 inventory=existing-database-with-document.yaml

New database with field

module "firestore" {
  source     = "./fabric/modules/firestore"
  project_id = "my-project"
  database = {
    name        = "my-database"
    location_id = "name5"
    type        = "FIRESTORE_NATIVE"
  }
  fields = {
    my-field-in-my-coll = {
      collection = "my-coll"
      field      = "my-field"
      indexes = [
        {
          order       = "ASCENDING"
          query_scope = "COLLECTION_GROUP"
        },
        {
          array_config = "CONTAINS"
        }
      ]
    }
  }
}
# tftest modules=1 resources=2 inventory=new-database-with-field.yaml

New database with index

module "firestore" {
  source     = "./fabric/modules/firestore"
  project_id = "my-project"
  database = {
    name        = "my-database"
    location_id = "name5"
    type        = "FIRESTORE_NATIVE"
  }
  indexes = {
    my-index = {
      collection = "my-coll"
      fields = [
        {
          field_path = "name"
          order      = "ASCENDING"
        },
        {
          field_path = "description"
          order      = "DESCENDING"
        }
      ]
    }
  }
}
# tftest modules=1 resources=2 inventory=new-database-with-index.yaml

Variables

name description type required default
database Database attributes. object({…})
project_id Project id. string
backup_schedule Backup schedule. object({…}) null
database_create Flag indicating whether the database should be created of not. string "true"
documents Documents. map(object({…})) {}
fields Fields. map(object({…})) {}
indexes Indexes. map(object({…})) {}

Outputs

name description sensitive
firestore_database Firestore database.
firestore_document_ids Firestore document ids.
firestore_documents Firestore documents.
firestore_field_ids Firestore field ids.
firestore_fields Firestore fields.
firestore_index_ids Firestore index ids.
firestore_indexes Firestore indexes.