googleFirestoreDatabase
A Cloud Firestore Database. Currently only one database is allowed per cloud project; this database must have a databaseId
of '(default)'.
To get more information about Database, see:
- API documentation
- How-to Guides
- Official Documentation
Example Usage - Firestore Database
resource "google_project" "project" {
project_id = "tf-test%{random_suffix}"
name = "tf-test%{random_suffix}"
org_id = "123456789"
}
resource "time_sleep" "wait_60_seconds" {
depends_on = [google_project.project]
create_duration = "60s"
}
resource "google_project_service" "firestore" {
project = google_project.project.project_id
service = "firestore.googleapis.com"
# Needed for CI tests for permissions to propagate, should not be needed for actual usage
depends_on = [time_sleep.wait_60_seconds]
}
resource "google_firestore_database" "database" {
project = google_project.project.project_id
name = "(default)"
location_id = "nam5"
type = "FIRESTORE_NATIVE"
concurrency_mode = "OPTIMISTIC"
app_engine_integration_mode = "DISABLED"
depends_on = [google_project_service.firestore]
}
Example Usage - Firestore Database Datastore Mode
resource "google_project" "project" {
project_id = "tf-test%{random_suffix}"
name = "tf-test%{random_suffix}"
org_id = "123456789"
}
resource "time_sleep" "wait_60_seconds" {
depends_on = [google_project.project]
create_duration = "60s"
}
resource "google_project_service" "firestore" {
project = google_project.project.project_id
service = "firestore.googleapis.com"
# Needed for CI tests for permissions to propagate, should not be needed for actual usage
depends_on = [time_sleep.wait_60_seconds]
}
resource "google_firestore_database" "datastore_mode_database" {
project = google_project.project.project_id
name = "(default)"
location_id = "nam5"
type = "DATASTORE_MODE"
depends_on = [google_project_service.firestore]
}
Argument Reference
The following arguments are supported:
-
name
- (Required) Required. The ID to use for the database, which will become the final component of the database's resource name. This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/ with first character a letter and the last a letter or a number. Must not be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/. "(default)" database id is also valid. -
locationId
- (Required) The location of the database. Available databases are listed at https://cloud.google.com/firestore/docs/locations. -
type
- (Required) The type of the database. See https://cloud.google.com/datastore/docs/firestore-or-datastore for information about how to choose. Possible values arefirestoreNative
anddatastoreMode
.
-
concurrencyMode
- (Optional) The concurrency control mode to use for this database. Possible values areoptimistic
,pessimistic
, andoptimisticWithEntityGroups
. -
appEngineIntegrationMode
- (Optional) The App Engine integration mode to use for this database. Possible values areenabled
anddisabled
. -
project
- (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Attributes Reference
In addition to the arguments listed above, the following computed attributes are exported:
-
id
- an identifier for the resource with formatprojects/{{project}}/databases/{{name}}
-
keyPrefix
- Output only. The keyPrefix for this database. This keyPrefix is used, in combination with the project id ("~") to construct the application id that is returned from the Cloud Datastore APIs in Google App Engine first generation runtimes. This value may be empty in which case the appid to use for URL-encoded keys is the project_id (eg: foo instead of v~foo). -
etag
- This checksum is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding. -
createTime
- The timestamp at which this database was created.
Timeouts
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.update
- Default is 20 minutes.delete
- Default is 20 minutes.
Import
Database can be imported using any of these accepted formats:
$ terraform import google_firestore_database.default projects/{{project}}/databases/{{name}}
$ terraform import google_firestore_database.default {{project}}/{{name}}
$ terraform import google_firestore_database.default {{name}}
User Project Overrides
This resource supports User Project Overrides.