azurermCosmosdbMongoCollection
Manages a Mongo Collection 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 azurermCosmosdbMongoDatabaseExample =
new azurerm.cosmosdbMongoDatabase.CosmosdbMongoDatabase(this, "example_1", {
account_name: dataAzurermCosmosdbAccountExample.name,
name: "tfex-cosmos-mongo-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.*/
azurermCosmosdbMongoDatabaseExample.overrideLogicalId("example");
const azurermCosmosdbMongoCollectionExample =
new azurerm.cosmosdbMongoCollection.CosmosdbMongoCollection(
this,
"example_2",
{
account_name: dataAzurermCosmosdbAccountExample.name,
database_name: azurermCosmosdbMongoDatabaseExample.name,
default_ttl_seconds: "777",
index: [
{
keys: ["_id"],
unique: true,
},
],
name: "tfex-cosmos-mongo-db",
resource_group_name: dataAzurermCosmosdbAccountExample.resourceGroupName,
shard_key: "uniqueKey",
throughput: 400,
}
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCosmosdbMongoCollectionExample.overrideLogicalId("example");
Argument Reference
The following arguments are supported:
name
- (Required) Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.resourceGroupName
- (Required) The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.accountName
- (Required) The name of the Cosmos DB Account in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.databaseName
- (Required) The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.shardKey
- (Optional) The name of the key to partition on for sharding. There must not be any other unique index keys. Changing this forces a new resource to be created.analyticalStorageTtl
- (Optional) The default time to live of Analytical Storage for this Mongo Collection. If present and the value is set to1
, it is equal to infinity, and items don’t expire by default. If present and the value is set to some numbern
– items will expiren
seconds after their last modified time.defaultTtlSeconds
- (Optional) The default Time To Live in seconds. If the value is1
, items are not automatically expired.index
- (Optional) One or moreindex
blocks as defined below.throughput
- (Optional) The throughput of the MongoDB collection (RU/s). Must be set in increments of100
. The minimum value is400
. This must be set upon database creation otherwise it cannot be updated without a manual terraform destroy-apply.autoscaleSettings
- (Optional) AnautoscaleSettings
block as defined below. This must be set upon database creation otherwise it cannot be updated without a manual terraform destroy-apply.
\~> Note: Switching between autoscale and manual throughput is not supported via Terraform and must be completed via the Azure Portal and refreshed.
An autoscaleSettings
block supports the following:
maxThroughput
- (Optional) The maximum throughput of the MongoDB collection (RU/s). Must be between1,000
and1,000,000
. Must be set in increments of1,000
. Conflicts withthroughput
.
The index
block supports the following:
-
keys
- (Required) Specifies the list of user settable keys for each Cosmos DB Mongo Collection. -
unique
- (Optional) Is the index unique or not? Defaults tofalse
.
\~> Note: An index with an "_id" key must be specified.
Attributes Reference
The following attributes are exported:
-
id
- The ID of the Cosmos DB Mongo Collection. -
systemIndexes
- One or moresystemIndexes
blocks as defined below.
The systemIndexes
block supports the following:
-
keys
- The list of system keys which are not settable for each Cosmos DB Mongo Collection. -
unique
- Identifies whether the table contains no duplicate values.
Timeouts
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 30 minutes) Used when creating the CosmosDB Mongo Collection.update
- (Defaults to 30 minutes) Used when updating the CosmosDB Mongo Collection.read
- (Defaults to 5 minutes) Used when retrieving the CosmosDB Mongo Collection.delete
- (Defaults to 30 minutes) Used when deleting the CosmosDB Mongo Collection.
Import
CosmosDB Mongo Collection can be imported using the resourceId
, e.g.