Google Datastore Index
This page shows how to write Terraform for Datastore Index and write them securely.
google_datastore_index (Terraform)
The Index in Datastore can be configured in Terraform with the resource name google_datastore_index
. The following sections describe 5 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "google_datastore_index" "team1" {
kind = "Team"
properties {
name = "program"
direction = "ASCENDING"
}
resource "google_datastore_index" "id_createdAt" {
kind = "price"
properties {
name = "id"
direction = "ASCENDING"
}
resource "google_datastore_index" "blob_status_updated_at" {
kind = "blob"
properties {
name = "Status"
direction = "ASCENDING"
}
resource "google_datastore_index" "person" {
kind = var.datastore_kind
properties {
name = "name"
direction = "ASCENDING"
}
resource "google_datastore_index" "person" {
kind = var.datastore_kind
properties {
name = "name"
direction = "ASCENDING"
}
Parameters
-
ancestor
optional - string
Policy for including ancestors in the index. Default value: "NONE" Possible values: ["NONE", "ALL_ANCESTORS"]
The index id.
-
kind
required - string
The entity kind which the index applies to.
-
project
optional computed - string -
properties
list block-
direction
required - string
The direction the index should optimize for sorting. Possible values: ["ASCENDING", "DESCENDING"]
-
name
required - string
The property name to index.
-
-
timeouts
single block
Explanation in Terraform Registry
Describes a composite index for Cloud Datastore. To get more information about Index, see:
- API documentation
- How-to Guides
- Official Documentation
Warning: This resource creates a Datastore Index on a project that has already enabled a Datastore-compatible database. If you haven't already enabled one, you can create a
google_app_engine_application
resource withdatabase_type
set to"CLOUD_DATASTORE_COMPATIBILITY"
to do so. Your Datastore location will be the same as the App Engine location specified.
Frequently asked questions
What is Google Datastore Index?
Google Datastore Index is a resource for Datastore of Google Cloud Platform. Settings can be wrote in Terraform.
Where can I find the example code for the Google Datastore Index?
For Terraform, the FIRST-Tech-Challenge/fmltc, gmenih341/scrappr and googleforgames/open-saves source code examples are useful. See the Terraform Example section for further details.