| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** 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: "Datastore" |
| description: |- |
| Describes a composite index for Cloud Datastore. |
| --- |
| |
| # google\_datastore\_index |
| |
| Describes a composite index for Cloud Datastore. |
| |
| |
| To get more information about Index, see: |
| |
| * [API documentation](https://cloud.google.com/datastore/docs/reference/admin/rest/v1/projects.indexes) |
| * How-to Guides |
| * [Official Documentation](https://cloud.google.com/datastore/docs/concepts/indexes) |
| |
| ~> **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. |
| |
| <div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=datastore_index&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank"> |
| <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| </a> |
| </div> |
| ## Example Usage - Datastore Index |
| |
| |
| ```hcl |
| resource "google_datastore_index" "default" { |
| kind = "foo" |
| properties { |
| name = "property_a" |
| direction = "ASCENDING" |
| } |
| properties { |
| name = "property_b" |
| direction = "ASCENDING" |
| } |
| } |
| ``` |
| |
| ## Argument Reference |
| |
| The following arguments are supported: |
| |
| |
| * `kind` - |
| (Required) |
| The entity kind which the index applies to. |
| |
| |
| - - - |
| |
| |
| * `ancestor` - |
| (Optional) |
| Policy for including ancestors in the index. |
| Default value is `NONE`. |
| Possible values are: `NONE`, `ALL_ANCESTORS`. |
| |
| * `properties` - |
| (Optional) |
| An ordered list of properties to index on. |
| Structure is [documented below](#nested_properties). |
| |
| * `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_properties"></a>The `properties` block supports: |
| |
| * `name` - |
| (Required) |
| The property name to index. |
| |
| * `direction` - |
| (Required) |
| The direction the index should optimize for sorting. |
| Possible values are: `ASCENDING`, `DESCENDING`. |
| |
| ## 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}}/indexes/{{index_id}}` |
| |
| * `index_id` - |
| The index id. |
| |
| |
| ## 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. |
| - `delete` - Default is 20 minutes. |
| |
| ## Import |
| |
| |
| Index can be imported using any of these accepted formats: |
| |
| * `projects/{{project}}/indexes/{{index_id}}` |
| * `{{project}}/{{index_id}}` |
| * `{{index_id}}` |
| |
| |
| In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Index using one of the formats above. For example: |
| |
| ```tf |
| import { |
| id = "projects/{{project}}/indexes/{{index_id}}" |
| to = google_datastore_index.default |
| } |
| ``` |
| |
| When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), Index can be imported using one of the formats above. For example: |
| |
| ``` |
| $ terraform import google_datastore_index.default projects/{{project}}/indexes/{{index_id}} |
| $ terraform import google_datastore_index.default {{project}}/{{index_id}} |
| $ terraform import google_datastore_index.default {{index_id}} |
| ``` |
| |
| ## User Project Overrides |
| |
| This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). |