gcp.firestore.Index
Explore with Pulumi AI
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:
- API documentation
- How-to Guides
Warning: This resource creates a Firestore Index on a project that already has a Firestore database. If you haven’t already created it, you may create a
gcp.firestore.Database
resource withtype
set to"FIRESTORE_NATIVE"
andlocation_id
set to your chosen location. If you wish to use App Engine, you may instead create agcp.appengine.Application
resource withdatabase_type
set to"CLOUD_FIRESTORE"
. Your Firestore location will be the same as the App Engine location specified.
Example Usage
Firestore Index Basic
using System.Collections.Generic;
using System.Linq;
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)
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<Index
Field Args> 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.
- Query
Scope string The scope at which a query is run. Default value is
COLLECTION
. Possible values are:COLLECTION
,COLLECTION_GROUP
.
- Collection string
The collection being indexed.
- Fields
[]Index
Field Args 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.
- Query
Scope string The scope at which a query is run. Default value is
COLLECTION
. Possible values are:COLLECTION
,COLLECTION_GROUP
.
- collection String
The collection being indexed.
- fields
List<Index
Field Args> 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.
- query
Scope String The scope at which a query is run. Default value is
COLLECTION
. Possible values are:COLLECTION
,COLLECTION_GROUP
.
- collection string
The collection being indexed.
- fields
Index
Field Args[] 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.
- query
Scope string The scope at which a query is run. Default value is
COLLECTION
. Possible values are:COLLECTION
,COLLECTION_GROUP
.
- collection str
The collection being indexed.
- fields
Sequence[Index
Field Args] 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
,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.
- query
Scope String The scope at which a query is run. Default value is
COLLECTION
. Possible values are:COLLECTION
,COLLECTION_GROUP
.
Outputs
All input properties are implicitly available as output properties. Additionally, the Index resource produces the following output properties:
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.
- Collection string
The collection being indexed.
- Database string
The Firestore database id. Defaults to
"(default)"
.- Fields
List<Index
Field Args> 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.
- Query
Scope string The scope at which a query is run. Default value is
COLLECTION
. Possible values are:COLLECTION
,COLLECTION_GROUP
.
- Collection string
The collection being indexed.
- Database string
The Firestore database id. Defaults to
"(default)"
.- Fields
[]Index
Field Args 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.
- Query
Scope string The scope at which a query is run. Default value is
COLLECTION
. Possible values are:COLLECTION
,COLLECTION_GROUP
.
- collection String
The collection being indexed.
- database String
The Firestore database id. Defaults to
"(default)"
.- fields
List<Index
Field Args> 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.
- query
Scope String The scope at which a query is run. Default value is
COLLECTION
. Possible values are:COLLECTION
,COLLECTION_GROUP
.
- collection string
The collection being indexed.
- database string
The Firestore database id. Defaults to
"(default)"
.- fields
Index
Field Args[] 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.
- query
Scope string The scope at which a query is run. Default value is
COLLECTION
. Possible values are:COLLECTION
,COLLECTION_GROUP
.
- collection str
The collection being indexed.
- database str
The Firestore database id. Defaults to
"(default)"
.- fields
Sequence[Index
Field Args] 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
,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.
- query
Scope String The scope at which a query is run. Default value is
COLLECTION
. Possible values are:COLLECTION
,COLLECTION_GROUP
.
Supporting Types
IndexField
- Array
Config string Indicates that this field supports operations on arrayValues. Only one of
order
andarrayConfig
can be specified. Possible values are:CONTAINS
.- Field
Path string Name of the field.
- Order string
Indicates that this field supports ordering by the specified order or comparing using =, <, <=, >, >=. Only one of
order
andarrayConfig
can be specified. Possible values are:ASCENDING
,DESCENDING
.
- Array
Config string Indicates that this field supports operations on arrayValues. Only one of
order
andarrayConfig
can be specified. Possible values are:CONTAINS
.- Field
Path string Name of the field.
- Order string
Indicates that this field supports ordering by the specified order or comparing using =, <, <=, >, >=. Only one of
order
andarrayConfig
can be specified. Possible values are:ASCENDING
,DESCENDING
.
- array
Config String Indicates that this field supports operations on arrayValues. Only one of
order
andarrayConfig
can be specified. Possible values are:CONTAINS
.- field
Path String Name of the field.
- order String
Indicates that this field supports ordering by the specified order or comparing using =, <, <=, >, >=. Only one of
order
andarrayConfig
can be specified. Possible values are:ASCENDING
,DESCENDING
.
- array
Config string Indicates that this field supports operations on arrayValues. Only one of
order
andarrayConfig
can be specified. Possible values are:CONTAINS
.- field
Path string Name of the field.
- order string
Indicates that this field supports ordering by the specified order or comparing using =, <, <=, >, >=. Only one of
order
andarrayConfig
can be specified. Possible values are:ASCENDING
,DESCENDING
.
- array_
config str Indicates that this field supports operations on arrayValues. Only one of
order
andarrayConfig
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
andarrayConfig
can be specified. Possible values are:ASCENDING
,DESCENDING
.
- array
Config String Indicates that this field supports operations on arrayValues. Only one of
order
andarrayConfig
can be specified. Possible values are:CONTAINS
.- field
Path String Name of the field.
- order String
Indicates that this field supports ordering by the specified order or comparing using =, <, <=, >, >=. Only one of
order
andarrayConfig
can be specified. Possible values are:ASCENDING
,DESCENDING
.
Import
Index can be imported using any of these accepted formats
$ pulumi import gcp:firestore/index:Index default {{name}}
Package Details
- Repository
- Google Cloud (GCP) Classic pulumi/pulumi-gcp
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
google-beta
Terraform Provider.