Google Cloud (GCP) Classic

v6.43.0 published on Tuesday, Nov 15, 2022 by Pulumi

Index

Cloud Firestore indexes enable simple and complex queries against documents in a database. This resource manages composite indexes and not single field indexes.

To get more information about Index, see:

Warning: This resource creates a Firestore Index on a project that already has Firestore enabled. If you haven’t already enabled it, you can create a gcp.appengine.Application resource with database_type set to "CLOUD_FIRESTORE" to do so. Your Firestore location will be the same as the App Engine location specified.

Example Usage

Firestore Index Basic

using System.Collections.Generic;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var my_index = new Gcp.Firestore.Index("my-index", new()
    {
        Collection = "chatrooms",
        Fields = new[]
        {
            new Gcp.Firestore.Inputs.IndexFieldArgs
            {
                FieldPath = "name",
                Order = "ASCENDING",
            },
            new Gcp.Firestore.Inputs.IndexFieldArgs
            {
                FieldPath = "description",
                Order = "DESCENDING",
            },
        },
        Project = "my-project-name",
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/firestore"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := firestore.NewIndex(ctx, "my-index", &firestore.IndexArgs{
			Collection: pulumi.String("chatrooms"),
			Fields: firestore.IndexFieldArray{
				&firestore.IndexFieldArgs{
					FieldPath: pulumi.String("name"),
					Order:     pulumi.String("ASCENDING"),
				},
				&firestore.IndexFieldArgs{
					FieldPath: pulumi.String("description"),
					Order:     pulumi.String("DESCENDING"),
				},
			},
			Project: pulumi.String("my-project-name"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.firestore.Index;
import com.pulumi.gcp.firestore.IndexArgs;
import com.pulumi.gcp.firestore.inputs.IndexFieldArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var my_index = new Index("my-index", IndexArgs.builder()        
            .collection("chatrooms")
            .fields(            
                IndexFieldArgs.builder()
                    .fieldPath("name")
                    .order("ASCENDING")
                    .build(),
                IndexFieldArgs.builder()
                    .fieldPath("description")
                    .order("DESCENDING")
                    .build())
            .project("my-project-name")
            .build());

    }
}
import pulumi
import pulumi_gcp as gcp

my_index = gcp.firestore.Index("my-index",
    collection="chatrooms",
    fields=[
        gcp.firestore.IndexFieldArgs(
            field_path="name",
            order="ASCENDING",
        ),
        gcp.firestore.IndexFieldArgs(
            field_path="description",
            order="DESCENDING",
        ),
    ],
    project="my-project-name")
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const my_index = new gcp.firestore.Index("my-index", {
    collection: "chatrooms",
    fields: [
        {
            fieldPath: "name",
            order: "ASCENDING",
        },
        {
            fieldPath: "description",
            order: "DESCENDING",
        },
    ],
    project: "my-project-name",
});
resources:
  my-index:
    type: gcp:firestore:Index
    properties:
      collection: chatrooms
      fields:
        - fieldPath: name
          order: ASCENDING
        - fieldPath: description
          order: DESCENDING
      project: my-project-name

Create Index Resource

new Index(name: string, args: IndexArgs, opts?: CustomResourceOptions);
@overload
def Index(resource_name: str,
          opts: Optional[ResourceOptions] = None,
          collection: Optional[str] = None,
          database: Optional[str] = None,
          fields: Optional[Sequence[IndexFieldArgs]] = None,
          project: Optional[str] = None,
          query_scope: Optional[str] = None)
@overload
def Index(resource_name: str,
          args: IndexArgs,
          opts: Optional[ResourceOptions] = None)
func NewIndex(ctx *Context, name string, args IndexArgs, opts ...ResourceOption) (*Index, error)
public Index(string name, IndexArgs args, CustomResourceOptions? opts = null)
public Index(String name, IndexArgs args)
public Index(String name, IndexArgs args, CustomResourceOptions options)
type: gcp:firestore:Index
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args IndexArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args IndexArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args IndexArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args IndexArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args IndexArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Index Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The Index resource accepts the following input properties:

Collection string

The collection being indexed.

Fields List<IndexFieldArgs>

The fields supported by this index. The last field entry is always for the field path __name__. If, on creation, __name__ was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, the __name__ will be ordered "ASCENDING" (unless explicitly specified otherwise). Structure is documented below.

Database string

The Firestore database id. Defaults to "(default)".

Project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

QueryScope string

The scope at which a query is run. Default value is COLLECTION. Possible values are COLLECTION and COLLECTION_GROUP.

Collection string

The collection being indexed.

Fields []IndexFieldArgs

The fields supported by this index. The last field entry is always for the field path __name__. If, on creation, __name__ was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, the __name__ will be ordered "ASCENDING" (unless explicitly specified otherwise). Structure is documented below.

Database string

The Firestore database id. Defaults to "(default)".

Project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

QueryScope string

The scope at which a query is run. Default value is COLLECTION. Possible values are COLLECTION and COLLECTION_GROUP.

collection String

The collection being indexed.

fields List<IndexFieldArgs>

The fields supported by this index. The last field entry is always for the field path __name__. If, on creation, __name__ was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, the __name__ will be ordered "ASCENDING" (unless explicitly specified otherwise). Structure is documented below.

database String

The Firestore database id. Defaults to "(default)".

project String

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

queryScope String

The scope at which a query is run. Default value is COLLECTION. Possible values are COLLECTION and COLLECTION_GROUP.

collection string

The collection being indexed.

fields IndexFieldArgs[]

The fields supported by this index. The last field entry is always for the field path __name__. If, on creation, __name__ was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, the __name__ will be ordered "ASCENDING" (unless explicitly specified otherwise). Structure is documented below.

database string

The Firestore database id. Defaults to "(default)".

project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

queryScope string

The scope at which a query is run. Default value is COLLECTION. Possible values are COLLECTION and COLLECTION_GROUP.

collection str

The collection being indexed.

fields Sequence[IndexFieldArgs]

The fields supported by this index. The last field entry is always for the field path __name__. If, on creation, __name__ was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, the __name__ will be ordered "ASCENDING" (unless explicitly specified otherwise). Structure is documented below.

database str

The Firestore database id. Defaults to "(default)".

project str

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

query_scope str

The scope at which a query is run. Default value is COLLECTION. Possible values are COLLECTION and COLLECTION_GROUP.

collection String

The collection being indexed.

fields List<Property Map>

The fields supported by this index. The last field entry is always for the field path __name__. If, on creation, __name__ was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, the __name__ will be ordered "ASCENDING" (unless explicitly specified otherwise). Structure is documented below.

database String

The Firestore database id. Defaults to "(default)".

project String

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

queryScope String

The scope at which a query is run. Default value is COLLECTION. Possible values are COLLECTION and COLLECTION_GROUP.

Outputs

All input properties are implicitly available as output properties. Additionally, the Index resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Name string

A server defined name for this index. Format: 'projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}'

Id string

The provider-assigned unique ID for this managed resource.

Name string

A server defined name for this index. Format: 'projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}'

id String

The provider-assigned unique ID for this managed resource.

name String

A server defined name for this index. Format: 'projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}'

id string

The provider-assigned unique ID for this managed resource.

name string

A server defined name for this index. Format: 'projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}'

id str

The provider-assigned unique ID for this managed resource.

name str

A server defined name for this index. Format: 'projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}'

id String

The provider-assigned unique ID for this managed resource.

name String

A server defined name for this index. Format: 'projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}'

Look up Existing Index Resource

Get an existing Index resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: IndexState, opts?: CustomResourceOptions): Index
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        collection: Optional[str] = None,
        database: Optional[str] = None,
        fields: Optional[Sequence[IndexFieldArgs]] = None,
        name: Optional[str] = None,
        project: Optional[str] = None,
        query_scope: Optional[str] = None) -> Index
func GetIndex(ctx *Context, name string, id IDInput, state *IndexState, opts ...ResourceOption) (*Index, error)
public static Index Get(string name, Input<string> id, IndexState? state, CustomResourceOptions? opts = null)
public static Index get(String name, Output<String> id, IndexState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Collection string

The collection being indexed.

Database string

The Firestore database id. Defaults to "(default)".

Fields List<IndexFieldArgs>

The fields supported by this index. The last field entry is always for the field path __name__. If, on creation, __name__ was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, the __name__ will be ordered "ASCENDING" (unless explicitly specified otherwise). Structure is documented below.

Name string

A server defined name for this index. Format: 'projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}'

Project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

QueryScope string

The scope at which a query is run. Default value is COLLECTION. Possible values are COLLECTION and COLLECTION_GROUP.

Collection string

The collection being indexed.

Database string

The Firestore database id. Defaults to "(default)".

Fields []IndexFieldArgs

The fields supported by this index. The last field entry is always for the field path __name__. If, on creation, __name__ was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, the __name__ will be ordered "ASCENDING" (unless explicitly specified otherwise). Structure is documented below.

Name string

A server defined name for this index. Format: 'projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}'

Project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

QueryScope string

The scope at which a query is run. Default value is COLLECTION. Possible values are COLLECTION and COLLECTION_GROUP.

collection String

The collection being indexed.

database String

The Firestore database id. Defaults to "(default)".

fields List<IndexFieldArgs>

The fields supported by this index. The last field entry is always for the field path __name__. If, on creation, __name__ was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, the __name__ will be ordered "ASCENDING" (unless explicitly specified otherwise). Structure is documented below.

name String

A server defined name for this index. Format: 'projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}'

project String

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

queryScope String

The scope at which a query is run. Default value is COLLECTION. Possible values are COLLECTION and COLLECTION_GROUP.

collection string

The collection being indexed.

database string

The Firestore database id. Defaults to "(default)".

fields IndexFieldArgs[]

The fields supported by this index. The last field entry is always for the field path __name__. If, on creation, __name__ was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, the __name__ will be ordered "ASCENDING" (unless explicitly specified otherwise). Structure is documented below.

name string

A server defined name for this index. Format: 'projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}'

project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

queryScope string

The scope at which a query is run. Default value is COLLECTION. Possible values are COLLECTION and COLLECTION_GROUP.

collection str

The collection being indexed.

database str

The Firestore database id. Defaults to "(default)".

fields Sequence[IndexFieldArgs]

The fields supported by this index. The last field entry is always for the field path __name__. If, on creation, __name__ was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, the __name__ will be ordered "ASCENDING" (unless explicitly specified otherwise). Structure is documented below.

name str

A server defined name for this index. Format: 'projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}'

project str

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

query_scope str

The scope at which a query is run. Default value is COLLECTION. Possible values are COLLECTION and COLLECTION_GROUP.

collection String

The collection being indexed.

database String

The Firestore database id. Defaults to "(default)".

fields List<Property Map>

The fields supported by this index. The last field entry is always for the field path __name__. If, on creation, __name__ was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, the __name__ will be ordered "ASCENDING" (unless explicitly specified otherwise). Structure is documented below.

name String

A server defined name for this index. Format: 'projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}'

project String

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

queryScope String

The scope at which a query is run. Default value is COLLECTION. Possible values are COLLECTION and COLLECTION_GROUP.

Supporting Types

IndexField

ArrayConfig string

Indicates that this field supports operations on arrayValues. Only one of order and arrayConfig can be specified. Possible values are CONTAINS.

FieldPath string

Name of the field.

Order string

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 and DESCENDING.

ArrayConfig string

Indicates that this field supports operations on arrayValues. Only one of order and arrayConfig can be specified. Possible values are CONTAINS.

FieldPath string

Name of the field.

Order string

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 and DESCENDING.

arrayConfig String

Indicates that this field supports operations on arrayValues. Only one of order and arrayConfig can be specified. Possible values are CONTAINS.

fieldPath String

Name of the field.

order String

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 and DESCENDING.

arrayConfig string

Indicates that this field supports operations on arrayValues. Only one of order and arrayConfig can be specified. Possible values are CONTAINS.

fieldPath string

Name of the field.

order string

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 and DESCENDING.

array_config str

Indicates that this field supports operations on arrayValues. Only one of order and arrayConfig can be specified. Possible values are CONTAINS.

field_path str

Name of the field.

order str

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 and DESCENDING.

arrayConfig String

Indicates that this field supports operations on arrayValues. Only one of order and arrayConfig can be specified. Possible values are CONTAINS.

fieldPath String

Name of the field.

order String

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 and DESCENDING.

Import

Index can be imported using any of these accepted formats

 $ pulumi import gcp:firestore/index:Index default {{name}}

Package Details

Repository
https://github.com/pulumi/pulumi-gcp
License
Apache-2.0
Notes

This Pulumi package is based on the google-beta Terraform Provider.