blob: 4f44c3c6c7a9fbd5e9aafb8e036f5a1a295be2ab [file] [log] [blame]
---
# ----------------------------------------------------------------------------
#
# *** 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: |-
Represents a single field in the database.
---
# google\_firestore\_field
Represents a single field in the database.
Fields are grouped by their "Collection Group", which represent all collections
in the database with the same id.
To get more information about Field, see:
* [API documentation](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases.collectionGroups.fields)
* How-to Guides
* [Official Documentation](https://cloud.google.com/firestore/docs/query-data/indexing)
~> **Warning:** This resource creates a Firestore Single Field override on a project that
already has a Firestore database. If you haven't already created it, you may
create a `google_firestore_database` resource with `location_id` set to your
chosen location.
## Example Usage - Firestore Field Basic
```hcl
resource "google_firestore_database" "database" {
project = "my-project-name"
name = "database-id"
location_id = "nam5"
type = "FIRESTORE_NATIVE"
delete_protection_state = "DELETE_PROTECTION_ENABLED"
deletion_policy = "DELETE"
}
resource "google_firestore_field" "basic" {
project = "my-project-name"
database = google_firestore_database.database.name
collection = "chatrooms_%{random_suffix}"
field = "basic"
index_config {
indexes {
order = "ASCENDING"
query_scope = "COLLECTION_GROUP"
}
indexes {
array_config = "CONTAINS"
}
}
}
```
## Example Usage - Firestore Field Timestamp
```hcl
resource "google_firestore_database" "database" {
project = "my-project-name"
name = "database-id"
location_id = "nam5"
type = "FIRESTORE_NATIVE"
delete_protection_state = "DELETE_PROTECTION_ENABLED"
deletion_policy = "DELETE"
}
resource "google_firestore_field" "timestamp" {
project = "my-project-name"
database = google_firestore_database.database.name
collection = "chatrooms"
field = "timestamp"
# enables a TTL policy for the document based on the value of entries with this field
ttl_config {}
// Disable all single field indexes for the timestamp property.
index_config {}
}
```
## Example Usage - Firestore Field Match Override
```hcl
resource "google_firestore_database" "database" {
project = "my-project-name"
name = "database-id"
location_id = "nam5"
type = "FIRESTORE_NATIVE"
delete_protection_state = "DELETE_PROTECTION_ENABLED"
deletion_policy = "DELETE"
}
resource "google_firestore_field" "match_override" {
project = "my-project-name"
database = google_firestore_database.database.name
collection = "chatrooms_%{random_suffix}"
field = "field_with_same_configuration_as_ancestor"
index_config {
indexes {
order = "ASCENDING"
}
indexes {
order = "DESCENDING"
}
indexes {
array_config = "CONTAINS"
}
}
}
```
## Argument Reference
The following arguments are supported:
* `collection` -
(Required)
The id of the collection group to configure.
* `field` -
(Required)
The id of the field to configure.
- - -
* `database` -
(Optional)
The Firestore database id. Defaults to `"(default)"`.
* `index_config` -
(Optional)
The single field index configuration for this field.
Creating an index configuration for this field will override any inherited configuration with the
indexes specified. Configuring the index configuration with an empty block disables all indexes on
the field.
Structure is [documented below](#nested_index_config).
* `ttl_config` -
(Optional)
The TTL configuration for this Field. If set to an empty block (i.e. `ttl_config {}`), a TTL policy is configured based on the field. If unset, a TTL policy is not configured (or will be disabled upon updating the resource).
Structure is [documented below](#nested_ttl_config).
* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
<a name="nested_index_config"></a>The `index_config` block supports:
* `indexes` -
(Optional)
The indexes to configure on the field. Order or array contains must be specified.
Structure is [documented below](#nested_indexes).
<a name="nested_indexes"></a>The `indexes` block supports:
* `query_scope` -
(Optional)
The scope at which a query is run. Collection scoped queries require you specify
the collection at query time. Collection group scope allows queries across all
collections with the same id.
Default value is `COLLECTION`.
Possible values are: `COLLECTION`, `COLLECTION_GROUP`.
* `order` -
(Optional)
Indicates that this field supports ordering by the specified order or comparing using =, <, <=, >, >=, !=.
Only one of `order` and `arrayConfig` can be specified.
Possible values are: `ASCENDING`, `DESCENDING`.
* `array_config` -
(Optional)
Indicates that this field supports operations on arrayValues. Only one of `order` and `arrayConfig` can
be specified.
Possible values are: `CONTAINS`.
<a name="nested_ttl_config"></a>The `ttl_config` block supports:
* `state` -
(Output)
The state of TTL (time-to-live) configuration for documents that have this Field set.
## Attributes Reference
In addition to the arguments listed above, the following computed attributes are exported:
* `id` - an identifier for the resource with format `{{name}}`
* `name` -
The name of this field. Format:
`projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/fields/{{field}}`
## 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
Field can be imported using any of these accepted formats:
* `{{name}}`
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Field using one of the formats above. For example:
```tf
import {
id = "{{name}}"
to = google_firestore_field.default
}
```
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), Field can be imported using one of the formats above. For example:
```
$ terraform import google_firestore_field.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).