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:
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"
}
}
}
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 {}
}
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"
}
}
}
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.
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.
project
- (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
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.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
.
The ttl_config
block supports:
state
-
(Output)
The state of TTL (time-to-live) configuration for documents that have this Field set.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}}
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.update
- Default is 20 minutes.delete
- Default is 20 minutes.Field can be imported using any of these accepted formats:
{{name}}
In Terraform v1.5.0 and later, use an import
block to import Field using one of the formats above. For example:
import {
id = "{{name}}"
to = google_firestore_field.default
}
When using the terraform import
command, Field can be imported using one of the formats above. For example:
$ terraform import google_firestore_field.default {{name}}
This resource supports User Project Overrides.