import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Cloud Firestore indexes enable simple and complex queries against documents in a database. * Both Firestore Native and Datastore Mode indexes are supported. * This resource manages composite indexes and not single field indexes. * To manage single field indexes, use the `gcp.firestore.Field` resource instead. * * To get more information about Index, see: * * * [API documentation](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases.collectionGroups.indexes) * * How-to Guides * * [Official Documentation](https://cloud.google.com/firestore/docs/query-data/indexing) * * > **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 and `locationId` set * to your chosen location. If you wish to use App Engine, you may * instead create a `gcp.appengine.Application` resource. * Your Firestore location will be the same as the App Engine location specified. * * ## Example Usage * * ### Firestore Index Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const database = new gcp.firestore.Database("database", { * project: "my-project-name", * name: "database-id", * locationId: "nam5", * type: "FIRESTORE_NATIVE", * deleteProtectionState: "DELETE_PROTECTION_DISABLED", * deletionPolicy: "DELETE", * }); * const my_index = new gcp.firestore.Index("my-index", { * project: "my-project-name", * database: database.name, * collection: "atestcollection", * fields: [ * { * fieldPath: "name", * order: "ASCENDING", * }, * { * fieldPath: "description", * order: "DESCENDING", * }, * ], * }); * ``` * ### Firestore Index Datastore Mode * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const database = new gcp.firestore.Database("database", { * project: "my-project-name", * name: "database-id-dm", * locationId: "nam5", * type: "DATASTORE_MODE", * deleteProtectionState: "DELETE_PROTECTION_DISABLED", * deletionPolicy: "DELETE", * }); * const my_index = new gcp.firestore.Index("my-index", { * project: "my-project-name", * database: database.name, * collection: "atestcollection", * queryScope: "COLLECTION_RECURSIVE", * apiScope: "DATASTORE_MODE_API", * density: "SPARSE_ALL", * fields: [ * { * fieldPath: "name", * order: "ASCENDING", * }, * { * fieldPath: "description", * order: "DESCENDING", * }, * ], * }); * ``` * ### Firestore Index Vector * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const database = new gcp.firestore.Database("database", { * project: "my-project-name", * name: "database-id-vector", * locationId: "nam5", * type: "FIRESTORE_NATIVE", * deleteProtectionState: "DELETE_PROTECTION_DISABLED", * deletionPolicy: "DELETE", * }); * const my_index = new gcp.firestore.Index("my-index", { * project: "my-project-name", * database: database.name, * collection: "atestcollection", * fields: [ * { * fieldPath: "field_name", * order: "ASCENDING", * }, * { * fieldPath: "__name__", * order: "ASCENDING", * }, * { * fieldPath: "description", * vectorConfig: { * dimension: 128, * flat: {}, * }, * }, * ], * }); * ``` * ### Firestore Index Name Descending * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const database = new gcp.firestore.Database("database", { * project: "my-project-name", * name: "database-id", * locationId: "nam5", * type: "FIRESTORE_NATIVE", * deleteProtectionState: "DELETE_PROTECTION_DISABLED", * deletionPolicy: "DELETE", * }); * const my_index = new gcp.firestore.Index("my-index", { * project: "my-project-name", * database: database.name, * collection: "atestcollection", * fields: [{ * fieldPath: "__name__", * order: "DESCENDING", * }], * }); * ``` * ### Firestore Index Mongodb Compatible Scope * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const database = new gcp.firestore.Database("database", { * project: "my-project-name", * name: "database-id-mongodb-compatible", * locationId: "nam5", * type: "FIRESTORE_NATIVE", * databaseEdition: "ENTERPRISE", * deleteProtectionState: "DELETE_PROTECTION_DISABLED", * deletionPolicy: "DELETE", * }); * const my_index = new gcp.firestore.Index("my-index", { * project: "my-project-name", * database: database.name, * collection: "atestcollection", * apiScope: "MONGODB_COMPATIBLE_API", * queryScope: "COLLECTION_GROUP", * multikey: true, * density: "DENSE", * fields: [ * { * fieldPath: "name", * order: "ASCENDING", * }, * { * fieldPath: "description", * order: "DESCENDING", * }, * ], * }); * ``` * ### Firestore Index Sparse Any * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const database = new gcp.firestore.Database("database", { * project: "my-project-name", * name: "database-id-sparse-any", * locationId: "nam5", * type: "FIRESTORE_NATIVE", * databaseEdition: "ENTERPRISE", * deleteProtectionState: "DELETE_PROTECTION_DISABLED", * deletionPolicy: "DELETE", * }); * const my_index = new gcp.firestore.Index("my-index", { * project: "my-project-name", * database: database.name, * collection: "atestcollection", * apiScope: "MONGODB_COMPATIBLE_API", * queryScope: "COLLECTION_GROUP", * multikey: true, * density: "SPARSE_ANY", * fields: [ * { * fieldPath: "name", * order: "ASCENDING", * }, * { * fieldPath: "description", * order: "DESCENDING", * }, * ], * }); * ``` * ### Firestore Index Unique * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const database = new gcp.firestore.Database("database", { * project: "my-project-name", * name: "database-id-unique", * locationId: "nam5", * type: "FIRESTORE_NATIVE", * databaseEdition: "ENTERPRISE", * deleteProtectionState: "DELETE_PROTECTION_DISABLED", * deletionPolicy: "DELETE", * }); * const my_index = new gcp.firestore.Index("my-index", { * project: "my-project-name", * database: database.name, * collection: "atestcollection", * apiScope: "MONGODB_COMPATIBLE_API", * queryScope: "COLLECTION_GROUP", * multikey: true, * density: "DENSE", * unique: true, * fields: [ * { * fieldPath: "name", * order: "ASCENDING", * }, * { * fieldPath: "description", * order: "DESCENDING", * }, * ], * }); * ``` * ### Firestore Index Skip Wait * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const database = new gcp.firestore.Database("database", { * project: "my-project-name", * name: "database-id-skip-wait", * locationId: "nam5", * type: "FIRESTORE_NATIVE", * deleteProtectionState: "DELETE_PROTECTION_DISABLED", * deletionPolicy: "DELETE", * }); * const my_index = new gcp.firestore.Index("my-index", { * project: "my-project-name", * database: database.name, * collection: "atestcollection", * fields: [ * { * fieldPath: "name", * order: "ASCENDING", * }, * { * fieldPath: "description", * order: "DESCENDING", * }, * ], * skipWait: true, * }); * ``` * ## Import * * Index can be imported using any of these accepted formats: * * * `{{name}}` * * When using the `pulumi import` command, Index can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:firestore/index:Index default {{name}} * ``` */ export declare class Index extends pulumi.CustomResource { /** * Get an existing Index resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: IndexState, opts?: pulumi.CustomResourceOptions): Index; /** * Returns true if the given object is an instance of Index. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is Index; /** * The API scope at which a query is run. * Default value is `ANY_API`. * Possible values are: `ANY_API`, `DATASTORE_MODE_API`, `MONGODB_COMPATIBLE_API`. */ readonly apiScope: pulumi.Output; /** * The collection being indexed. */ readonly collection: pulumi.Output; /** * The Firestore database id. Defaults to `"(default)"`. */ readonly database: pulumi.Output; /** * Deletion behavior for this index. * If the deletion policy is `PREVENT`, the index cannot be deleted and a terraform destroy will fail. * If the deletion policy is `DELETE`, the index will both be removed from Terraform state and deleted from Google Cloud upon destruction. * The default value is `DELETE`. */ readonly deletionPolicy: pulumi.Output; /** * The density configuration for this index. * Possible values are: `SPARSE_ALL`, `SPARSE_ANY`, `DENSE`. */ readonly density: pulumi.Output; /** * The fields supported by this index. The last non-stored 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. */ readonly fields: pulumi.Output; /** * Optional. Whether the index is multikey. By default, the index is not multikey. For non-multikey indexes, none of the paths in the index definition reach or traverse an array, except via an explicit array index. For multikey indexes, at most one of the paths in the index definition reach or traverse an array, except via an explicit array index. Violations will result in errors. Note this field only applies to indexes with MONGODB_COMPATIBLE_API ApiScope. */ readonly multikey: pulumi.Output; /** * A server defined name for this index. Format: * `projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}` */ readonly name: pulumi.Output; /** * The ID of the project in which the resource belongs. * If it is not provided, the provider project is used. */ readonly project: pulumi.Output; /** * The scope at which a query is run. * Default value is `COLLECTION`. * Possible values are: `COLLECTION`, `COLLECTION_GROUP`, `COLLECTION_RECURSIVE`. */ readonly queryScope: pulumi.Output; /** * Whether to skip waiting for the index to be created. */ readonly skipWait: pulumi.Output; /** * Whether it is an unique index. Unique index ensures all values for the indexed field(s) are unique across documents. */ readonly unique: pulumi.Output; /** * Create a Index resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: IndexArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering Index resources. */ export interface IndexState { /** * The API scope at which a query is run. * Default value is `ANY_API`. * Possible values are: `ANY_API`, `DATASTORE_MODE_API`, `MONGODB_COMPATIBLE_API`. */ apiScope?: pulumi.Input; /** * The collection being indexed. */ collection?: pulumi.Input; /** * The Firestore database id. Defaults to `"(default)"`. */ database?: pulumi.Input; /** * Deletion behavior for this index. * If the deletion policy is `PREVENT`, the index cannot be deleted and a terraform destroy will fail. * If the deletion policy is `DELETE`, the index will both be removed from Terraform state and deleted from Google Cloud upon destruction. * The default value is `DELETE`. */ deletionPolicy?: pulumi.Input; /** * The density configuration for this index. * Possible values are: `SPARSE_ALL`, `SPARSE_ANY`, `DENSE`. */ density?: pulumi.Input; /** * The fields supported by this index. The last non-stored 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. */ fields?: pulumi.Input[]>; /** * Optional. Whether the index is multikey. By default, the index is not multikey. For non-multikey indexes, none of the paths in the index definition reach or traverse an array, except via an explicit array index. For multikey indexes, at most one of the paths in the index definition reach or traverse an array, except via an explicit array index. Violations will result in errors. Note this field only applies to indexes with MONGODB_COMPATIBLE_API ApiScope. */ multikey?: pulumi.Input; /** * A server defined name for this index. Format: * `projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}` */ name?: pulumi.Input; /** * The ID of the project in which the resource belongs. * If it is not provided, the provider project is used. */ project?: pulumi.Input; /** * The scope at which a query is run. * Default value is `COLLECTION`. * Possible values are: `COLLECTION`, `COLLECTION_GROUP`, `COLLECTION_RECURSIVE`. */ queryScope?: pulumi.Input; /** * Whether to skip waiting for the index to be created. */ skipWait?: pulumi.Input; /** * Whether it is an unique index. Unique index ensures all values for the indexed field(s) are unique across documents. */ unique?: pulumi.Input; } /** * The set of arguments for constructing a Index resource. */ export interface IndexArgs { /** * The API scope at which a query is run. * Default value is `ANY_API`. * Possible values are: `ANY_API`, `DATASTORE_MODE_API`, `MONGODB_COMPATIBLE_API`. */ apiScope?: pulumi.Input; /** * The collection being indexed. */ collection: pulumi.Input; /** * The Firestore database id. Defaults to `"(default)"`. */ database?: pulumi.Input; /** * Deletion behavior for this index. * If the deletion policy is `PREVENT`, the index cannot be deleted and a terraform destroy will fail. * If the deletion policy is `DELETE`, the index will both be removed from Terraform state and deleted from Google Cloud upon destruction. * The default value is `DELETE`. */ deletionPolicy?: pulumi.Input; /** * The density configuration for this index. * Possible values are: `SPARSE_ALL`, `SPARSE_ANY`, `DENSE`. */ density?: pulumi.Input; /** * The fields supported by this index. The last non-stored 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. */ fields: pulumi.Input[]>; /** * Optional. Whether the index is multikey. By default, the index is not multikey. For non-multikey indexes, none of the paths in the index definition reach or traverse an array, except via an explicit array index. For multikey indexes, at most one of the paths in the index definition reach or traverse an array, except via an explicit array index. Violations will result in errors. Note this field only applies to indexes with MONGODB_COMPATIBLE_API ApiScope. */ multikey?: pulumi.Input; /** * The ID of the project in which the resource belongs. * If it is not provided, the provider project is used. */ project?: pulumi.Input; /** * The scope at which a query is run. * Default value is `COLLECTION`. * Possible values are: `COLLECTION`, `COLLECTION_GROUP`, `COLLECTION_RECURSIVE`. */ queryScope?: pulumi.Input; /** * Whether to skip waiting for the index to be created. */ skipWait?: pulumi.Input; /** * Whether it is an unique index. Unique index ensures all values for the indexed field(s) are unique across documents. */ unique?: pulumi.Input; }