Skip to content

azurermCosmosdbGremlinGraph

Manages a Gremlin Graph within a Cosmos DB Account.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const dataAzurermCosmosdbAccountExample =
  new azurerm.dataAzurermCosmosdbAccount.DataAzurermCosmosdbAccount(
    this,
    "example",
    {
      name: "tfex-cosmosdb-account",
      resource_group_name: "tfex-cosmosdb-account-rg",
    }
  );
const azurermCosmosdbGremlinDatabaseExample =
  new azurerm.cosmosdbGremlinDatabase.CosmosdbGremlinDatabase(
    this,
    "example_1",
    {
      account_name: dataAzurermCosmosdbAccountExample.name,
      name: "tfex-cosmos-gremlin-db",
      resource_group_name: dataAzurermCosmosdbAccountExample.resourceGroupName,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCosmosdbGremlinDatabaseExample.overrideLogicalId("example");
const azurermCosmosdbGremlinGraphExample =
  new azurerm.cosmosdbGremlinGraph.CosmosdbGremlinGraph(this, "example_2", {
    account_name: dataAzurermCosmosdbAccountExample.name,
    conflict_resolution_policy: [
      {
        conflict_resolution_path: "/_ts",
        mode: "LastWriterWins",
      },
    ],
    database_name: azurermCosmosdbGremlinDatabaseExample.name,
    index_policy: [
      {
        automatic: true,
        excluded_paths: ['/"_etag"/?'],
        included_paths: ["/*"],
        indexing_mode: "consistent",
      },
    ],
    name: "tfex-cosmos-gremlin-graph",
    partition_key_path: "/Example",
    resource_group_name: dataAzurermCosmosdbAccountExample.resourceGroupName,
    throughput: 400,
    unique_key: [
      {
        paths: ["/definition/id1", "/definition/id2"],
      },
    ],
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCosmosdbGremlinGraphExample.overrideLogicalId("example");

-> NOTE: The CosmosDB Account needs to have the enableGremlin capability enabled to use this resource - which can be done by adding this to the capabilities list within the azurermCosmosdbAccount resource.

Argument Reference

The following arguments are supported:

  • name - (Required) Specifies the name of the Cosmos DB Gremlin Graph. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the resource group in which the Cosmos DB Gremlin Graph is created. Changing this forces a new resource to be created.

  • accountName - (Required) The name of the CosmosDB Account to create the Gremlin Graph within. Changing this forces a new resource to be created.

  • databaseName - (Required) The name of the Cosmos DB Graph Database in which the Cosmos DB Gremlin Graph is created. Changing this forces a new resource to be created.

  • partitionKeyPath - (Required) Define a partition key. Changing this forces a new resource to be created.

  • partitionKeyVersion - (Optional) Define a partition key version. Changing this forces a new resource to be created. Possible values are 1and 2. This should be set to 2 in order to use large partition keys.

  • throughput - (Optional) The throughput of the Gremlin graph (RU/s). Must be set in increments of 100. The minimum value is 400. This must be set upon database creation otherwise it cannot be updated without a manual terraform destroy-apply.

  • defaultTtl - (Optional) The default time to live (TTL) of the Gremlin graph. If the value is missing or set to "-1", items don’t expire.

  • autoscaleSettings - (Optional) An autoscaleSettings block as defined below. This must be set upon database creation otherwise it cannot be updated without a manual terraform destroy-apply. Requires partitionKeyPath to be set.

\~> Note: Switching between autoscale and manual throughput is not supported via Terraform and must be completed via the Azure Portal and refreshed.

  • indexPolicy - (Optional) The configuration of the indexing policy. One or more indexPolicy blocks as defined below.

  • conflictResolutionPolicy - (Optional) A conflictResolutionPolicy blocks as defined below. Changing this forces a new resource to be created.

  • uniqueKey - (Optional) One or more uniqueKey blocks as defined below. Changing this forces a new resource to be created.


An autoscaleSettings block supports the following:

  • maxThroughput - (Optional) The maximum throughput of the Gremlin graph (RU/s). Must be between 1,000 and 1,000,000. Must be set in increments of 1,000. Conflicts with throughput.

An indexPolicy block supports the following:

  • automatic - (Optional) Indicates if the indexing policy is automatic. Defaults to true.

  • indexingMode - (Required) Indicates the indexing mode. Possible values include: consistent, lazy, none.

  • includedPaths - (Optional) List of paths to include in the indexing. Required if indexingMode is consistent or lazy.

  • excludedPaths - (Optional) List of paths to exclude from indexing. Required if indexingMode is consistent or lazy.

  • compositeIndex - (Optional) One or more compositeIndex blocks as defined below.

  • spatialIndex - (Optional) One or more spatialIndex blocks as defined below.


A spatialIndex block supports the following:

  • path - (Required) Path for which the indexing behaviour applies to. According to the service design, all spatial types including lineString, multiPolygon, point, and polygon will be applied to the path.

An conflictResolutionPolicy block supports the following:

  • mode - (Required) Indicates the conflict resolution mode. Possible values include: lastWriterWins, custom.

  • conflictResolutionPath - (Optional) The conflict resolution path in the case of LastWriterWins mode.

  • conflictResolutionProcedure - (Optional) The procedure to resolve conflicts in the case of custom mode.


An uniqueKey block supports the following:

  • paths - (Required) A list of paths to use for this unique key. Changing this forces a new resource to be created.

A compositeIndex block supports the following:

  • index - (Required) One or more index blocks as defined below.

An index block supports the following:

  • path - (Required) Path for which the indexing behaviour applies to.

  • order - (Required) Order of the index. Possible values are ascending or descending.

Attributes Reference

The following attributes are exported:

  • id - The ID of the CosmosDB Gremlin Graph.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the CosmosDB Gremlin Graph.
  • update - (Defaults to 30 minutes) Used when updating the CosmosDB Gremlin Graph.
  • read - (Defaults to 5 minutes) Used when retrieving the CosmosDB Gremlin Graph.
  • delete - (Defaults to 30 minutes) Used when deleting the CosmosDB Gremlin Graph.

Import

Cosmos Gremlin Graphs can be imported using the resourceId, e.g.

terraform import azurerm_cosmosdb_gremlin_graph.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/gremlinDatabases/db1/graphs/graphs1