| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** AUTO GENERATED CODE *** Type: MMv1 *** |
| # |
| # ---------------------------------------------------------------------------- |
| # |
| # This file is automatically generated by Magic Modules and manual |
| # changes will be clobbered when the file is regenerated. |
| # |
| # Please read more about how to change this file in |
| # .github/CONTRIBUTING.md. |
| # |
| # ---------------------------------------------------------------------------- |
| subcategory: "Firestore" |
| description: |- |
| A Cloud Firestore Database. |
| --- |
| |
| # google\_firestore\_database |
| |
| A Cloud Firestore Database. |
| |
| If you wish to use Firestore with App Engine, use the |
| [`google_app_engine_application`](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/app_engine_application) |
| resource instead. If you were previously using the `google_app_engine_application` resource exclusively for managing a Firestore database |
| and would like to use the `google_firestore_database` resource instead, please follow the instructions |
| [here](https://cloud.google.com/firestore/docs/app-engine-requirement). |
| |
| |
| To get more information about Database, see: |
| |
| * [API documentation](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases) |
| * How-to Guides |
| * [Official Documentation](https://cloud.google.com/firestore/docs/) |
| |
| ## Example Usage - Firestore Default Database |
| |
| |
| ```hcl |
| resource "google_firestore_database" "database" { |
| project = "my-project-name" |
| name = "(default)" |
| location_id = "nam5" |
| type = "FIRESTORE_NATIVE" |
| } |
| ``` |
| ## Example Usage - Firestore Database |
| |
| |
| ```hcl |
| resource "google_firestore_database" "database" { |
| project = "my-project-name" |
| name = "database-id" |
| location_id = "nam5" |
| type = "FIRESTORE_NATIVE" |
| concurrency_mode = "OPTIMISTIC" |
| app_engine_integration_mode = "DISABLED" |
| point_in_time_recovery_enablement = "POINT_IN_TIME_RECOVERY_ENABLED" |
| delete_protection_state = "DELETE_PROTECTION_ENABLED" |
| deletion_policy = "DELETE" |
| } |
| ``` |
| ## Example Usage - Firestore Default Database In Datastore Mode |
| |
| |
| ```hcl |
| resource "google_firestore_database" "datastore_mode_database" { |
| project = "my-project-name" |
| name = "(default)" |
| location_id = "nam5" |
| type = "DATASTORE_MODE" |
| } |
| ``` |
| ## Example Usage - Firestore Database In Datastore Mode |
| |
| |
| ```hcl |
| resource "google_firestore_database" "datastore_mode_database" { |
| project = "my-project-name" |
| name = "database-id" |
| location_id = "nam5" |
| type = "DATASTORE_MODE" |
| concurrency_mode = "OPTIMISTIC" |
| app_engine_integration_mode = "DISABLED" |
| point_in_time_recovery_enablement = "POINT_IN_TIME_RECOVERY_ENABLED" |
| delete_protection_state = "DELETE_PROTECTION_ENABLED" |
| deletion_policy = "DELETE" |
| } |
| ``` |
| |
| ## Argument Reference |
| |
| The following arguments are supported: |
| |
| |
| * `name` - |
| (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. |
| |
| * `location_id` - |
| (Required) |
| The location of the database. Available locations 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 are: `FIRESTORE_NATIVE`, `DATASTORE_MODE`. |
| |
| |
| - - - |
| |
| |
| * `concurrency_mode` - |
| (Optional) |
| The concurrency control mode to use for this database. |
| Possible values are: `OPTIMISTIC`, `PESSIMISTIC`, `OPTIMISTIC_WITH_ENTITY_GROUPS`. |
| |
| * `app_engine_integration_mode` - |
| (Optional) |
| The App Engine integration mode to use for this database. |
| Possible values are: `ENABLED`, `DISABLED`. |
| |
| * `point_in_time_recovery_enablement` - |
| (Optional) |
| Whether to enable the PITR feature on this database. |
| If `POINT_IN_TIME_RECOVERY_ENABLED` is selected, reads are supported on selected versions of the data from within the past 7 days. |
| versionRetentionPeriod and earliestVersionTime can be used to determine the supported versions. These include reads against any timestamp within the past hour |
| and reads against 1-minute snapshots beyond 1 hour and within 7 days. |
| If `POINT_IN_TIME_RECOVERY_DISABLED` is selected, reads are supported on any version of the data from within the past 1 hour. |
| Default value is `POINT_IN_TIME_RECOVERY_DISABLED`. |
| Possible values are: `POINT_IN_TIME_RECOVERY_ENABLED`, `POINT_IN_TIME_RECOVERY_DISABLED`. |
| |
| * `delete_protection_state` - |
| (Optional) |
| State of delete protection for the database. |
| When delete protection is enabled, this database cannot be deleted. |
| The default value is `DELETE_PROTECTION_STATE_UNSPECIFIED`, which is currently equivalent to `DELETE_PROTECTION_DISABLED`. |
| **Note:** Additionally, to delete this database using `terraform destroy`, `deletion_policy` must be set to `DELETE`. |
| Possible values are: `DELETE_PROTECTION_STATE_UNSPECIFIED`, `DELETE_PROTECTION_ENABLED`, `DELETE_PROTECTION_DISABLED`. |
| |
| * `project` - (Optional) The ID of the project in which the resource belongs. |
| If it is not provided, the provider project is used. |
| |
| * `deletion_policy` - (Optional) Deletion behavior for this database. |
| If the deletion policy is `ABANDON`, the database will be removed from Terraform state but not deleted from Google Cloud upon destruction. |
| If the deletion policy is `DELETE`, the database will both be removed from Terraform state and deleted from Google Cloud upon destruction. |
| The default value is `ABANDON`. |
| See also `delete_protection`. |
| |
| |
| ## Attributes Reference |
| |
| In addition to the arguments listed above, the following computed attributes are exported: |
| |
| * `id` - an identifier for the resource with format `projects/{{project}}/databases/{{name}}` |
| |
| * `key_prefix` - |
| 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` - |
| Output only. 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. |
| |
| * `create_time` - |
| Output only. The timestamp at which this database was created. |
| |
| * `update_time` - |
| Output only. The timestamp at which this database was most recently updated. |
| |
| * `uid` - |
| Output only. The system-generated UUID4 for this Database. |
| |
| * `version_retention_period` - |
| Output only. The period during which past versions of data are retained in the database. |
| Any read or query can specify a readTime within this window, and will read the state of the database at that time. |
| If the PITR feature is enabled, the retention period is 7 days. Otherwise, the retention period is 1 hour. |
| A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s". |
| |
| * `earliest_version_time` - |
| Output only. The earliest timestamp at which older versions of the data can be read from the database. See versionRetentionPeriod above; this field is populated with now - versionRetentionPeriod. |
| This value is continuously updated, and becomes stale the moment it is queried. If you are using this value to recover data, make sure to account for the time from the moment when the value is queried to the moment when you initiate the recovery. |
| A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z". |
| |
| |
| ## Timeouts |
| |
| This resource provides the following |
| [Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-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: |
| |
| * `projects/{{project}}/databases/{{name}}` |
| * `{{project}}/{{name}}` |
| * `{{name}}` |
| |
| |
| In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Database using one of the formats above. For example: |
| |
| ```tf |
| import { |
| id = "projects/{{project}}/databases/{{name}}" |
| to = google_firestore_database.default |
| } |
| ``` |
| |
| When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), Database can be imported using one of the formats above. For example: |
| |
| ``` |
| $ 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](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). |