This terraform module is used to create a Cloud Firestore database
The resources/services/activations/deletions that this module will create/trigger are:
- Creates a Cloud Firestore database.
- Creates a daily/weekly backup schedule for the Firestore database.
- Creates composite indexes for the database.
- Creates single fields exempt from default indexing for the database.
Basic usage of this module is as follows:
module "firestore_infra" {
source = "terraform-google-modules/firestore/google"
project_id = "<PROJECT_ID>"
database_id = "firestore-test-db"
location_id = "us-central1"
database_type = "FIRESTORE_NATIVE"
concurrency_mode = "OPTIMISTIC"
delete_protection_state = "DELETE_PROTECTION_DISABLED"
point_in_time_recovery_enablement = "POINT_IN_TIME_RECOVERY_DISABLED"
deletion_policy = "ABANDON"
backup_schedule_configuration = {
daily_recurrence = {}
retention = "2419200s"
}
composite_index_configuration = [
{
index_id = "my-index1"
collection = "terraform-firestore-collection"
query_scope = "COLLECTION"
api_scope = "ANY_API"
fields = [
{
field_path = "field1"
order = "ASCENDING"
},
{
field_path = "field2"
order = "DESCENDING"
}
]
}
]
field_configuration = [
{
collection = "reviews"
field = "field3"
ascending_index_query_scope = ["COLLECTION_GROUP"]
descending_index_query_scope = ["COLLECTION_GROUP"]
array_index_query_scope = ["COLLECTION"]
},
{
collection = "reviews"
field = "field4"
ascending_index_query_scope = ["COLLECTION_GROUP", "COLLECTION_GROUP"]
}
]
}
Functional examples are included in the examples directory.
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| backup_schedule_configuration | Backup schedule configuration for the Firestore Database. | object({ |
null |
no |
| composite_index_configuration | Composite index configuration for the Firestore Database. | list(object({ |
[] |
no |
| concurrency_mode | Concurrency control mode to be used for the Firestore Database. | string |
"PESSIMISTIC" |
no |
| database_edition | The database edition used to create the Firestore database. | string |
"STANDARD" |
no |
| database_id | Unique identifier of the Firestore Database. | string |
n/a | yes |
| database_type | Database type used to created the Firestore Database. | string |
"FIRESTORE_NATIVE" |
no |
| delete_protection_state | Determines whether deletion protection is enabled or not for the Firestore Database. | string |
"DELETE_PROTECTION_ENABLED" |
no |
| deletion_policy | Deletion policy enforced when Firestore Database is destroyed via Terraform. | string |
"DELETE" |
no |
| field_configuration | Single field configurations for the Firestore Database. | list(object({ |
[] |
no |
| kms_key_name | The resource ID of the Customer-managed Encryption Key (CMEK) using which the created database will be encrypted. | string |
null |
no |
| location | The location in which the Firesotre Database is created. | string |
n/a | yes |
| point_in_time_recovery_enablement | Determines whether point-in-time recovery is enabled for the Firestore Database. | string |
"POINT_IN_TIME_RECOVERY_ENABLED" |
no |
| project_id | The ID of the project in which the Firestore resources are created. | string |
n/a | yes |
| Name | Description |
|---|---|
| composite_index_ids | List of composite indices for the firestore database. |
| daily_backup_schedule_id | The unique backup schedule identifier across all locations and databases for the given project. |
| database_id | The full database resource name of the firestore database, in the format projects/{{project_id}}/databases/{{name}} |
| database_resource_id | The database id of the firestore database. |
| field_ids | List of firestore fields created for the database. |
| weekly_backup_schedule_id | The unique backup schedule identifier across all locations and databases for the given project. |
These sections describe requirements for using this module.
The following dependencies must be available:
- Terraform v0.13
- Terraform Provider for GCP plugin v3.0
A service account with the following roles must be used to provision the resources of this module:
- Storage Admin:
roles/storage.admin
The Project Factory module and the IAM module may be used in combination to provision a service account with the necessary roles applied.
A project with the following APIs enabled must be used to host the resources of this module:
- Google Cloud Storage JSON API:
storage-api.googleapis.com
The Project Factory module can be used to provision a project with the necessary APIs enabled.
Refer to the contribution guidelines for information on contributing to this module.
Please see our security disclosure process.