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

indexes.tf#L1
resource "google_datastore_index" "team1" {
  kind = "Team"
  properties {
    name = "program"
    direction = "ASCENDING"
  }
datastore_index.tf#L1
resource "google_datastore_index" "id_createdAt" {
  kind = "price"
  properties {
    name = "id"
    direction = "ASCENDING"
  }
datastore.tf#L17
resource "google_datastore_index" "blob_status_updated_at" {
  kind = "blob"
  properties {
    name = "Status"
    direction = "ASCENDING"
  }
ds-input-table.tf#L1
resource "google_datastore_index" "person" {
  kind = var.datastore_kind
  properties {
    name = "name"
    direction = "ASCENDING"
  }
ds-input-table.tf#L1
resource "google_datastore_index" "person" {
  kind = var.datastore_kind
  properties {
    name = "name"
    direction = "ASCENDING"
  }

Review your Terraform file for Google best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Policy for including ancestors in the index. Default value: "NONE" Possible values: ["NONE", "ALL_ANCESTORS"]

  • id optional computed - string
  • index_id optional computed - string

The index id.

The entity kind which the index applies to.

  • project optional computed - string
  • properties list block

    The direction the index should optimize for sorting. Possible values: ["ASCENDING", "DESCENDING"]

    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 with database_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.

security-icon

Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.