azurermCosmosdbSqlContainer
Manages a SQL Container 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 azurermCosmosdbSqlDatabaseExample =
new azurerm.cosmosdbSqlDatabase.CosmosdbSqlDatabase(this, "example_1", {
account_name: dataAzurermCosmosdbAccountExample.name,
name: "example-acsd",
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.*/
azurermCosmosdbSqlDatabaseExample.overrideLogicalId("example");
const azurermCosmosdbSqlContainerExample =
new azurerm.cosmosdbSqlContainer.CosmosdbSqlContainer(this, "example_2", {
account_name: dataAzurermCosmosdbAccountExample.name,
database_name: azurermCosmosdbSqlDatabaseExample.name,
indexing_policy: [
{
excluded_path: [
{
path: "/excluded/?",
},
],
included_path: [
{
path: "/*",
},
{
path: "/included/?",
},
],
indexing_mode: "consistent",
},
],
name: "example-container",
partition_key_path: "/definition/id",
partition_key_version: 1,
resource_group_name: dataAzurermCosmosdbAccountExample.resourceGroupName,
throughput: 400,
unique_key: [
{
paths: ["/definition/idlong", "/definition/idshort"],
},
],
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCosmosdbSqlContainerExample.overrideLogicalId("example");
Argument Reference
The following arguments are supported:
-
name
- (Required) Specifies the name of the Cosmos DB SQL Container. Changing this forces a new resource to be created. -
resourceGroupName
- (Required) The name of the resource group in which the Cosmos DB SQL Container is created. Changing this forces a new resource to be created. -
accountName
- (Required) The name of the Cosmos DB Account to create the container within. Changing this forces a new resource to be created. -
databaseName
- (Required) The name of the Cosmos DB SQL Database to create the container within. 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 are1
and2
. This should be set to2
in order to use large partition keys. -
uniqueKey
- (Optional) One or moreuniqueKey
blocks as defined below. Changing this forces a new resource to be created. -
throughput
- (Optional) The throughput of SQL container (RU/s). Must be set in increments of100
. The minimum value is400
. This must be set upon container 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. RequirespartitionKeyPath
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.
-
indexingPolicy
- (Optional) AnindexingPolicy
block as defined below. -
defaultTtl
- (Optional) The default time to live of SQL container. If missing, items are not expired automatically. 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. -
analyticalStorageTtl
- (Optional) The default time to live of Analytical Storage for this SQL container. 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. -
conflictResolutionPolicy
- (Optional) AconflictResolutionPolicy
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 SQL container (RU/s). Must be between1,000
and1,000,000
. Must be set in increments of1,000
. Conflicts withthroughput
.
A 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.
An indexingPolicy
block supports the following:
-
indexingMode
- (Optional) Indicates the indexing mode. Possible values include:consistent
andnone
. Defaults toconsistent
. -
includedPath
- (Optional) One or moreincludedPath
blocks as defined below. EitherincludedPath
orexcludedPath
must contain thepath
/*
-
excludedPath
- (Optional) One or moreexcludedPath
blocks as defined below. EitherincludedPath
orexcludedPath
must contain thepath
/*
-
compositeIndex
- (Optional) One or morecompositeIndex
blocks as defined below. -
spatialIndex
- (Optional) One or morespatialIndex
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 includinglineString
,multiPolygon
,point
, andpolygon
will be applied to the path.
An includedPath
block supports the following:
path
- (Required) Path for which the indexing behaviour applies to.
An excludedPath
block supports the following:
path
- (Required) Path that is excluded from indexing.
A compositeIndex
block supports the following:
index
- (Required) One or moreindex
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 areascending
ordescending
.
A 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 oflastWriterWins
mode. -
conflictResolutionProcedure
- (Optional) The procedure to resolve conflicts in the case ofcustom
mode.
Attributes Reference
The following attributes are exported:
id
- The ID of the CosmosDB SQL Container.
A spatialIndex
block exports the following:
types
- A set of spatial types of the path.
Timeouts
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 30 minutes) Used when creating the CosmosDB SQL Container.update
- (Defaults to 30 minutes) Used when updating the CosmosDB SQL Container.read
- (Defaults to 5 minutes) Used when retrieving the CosmosDB SQL Container.delete
- (Defaults to 30 minutes) Used when deleting the CosmosDB SQL Container.
Import
Cosmos SQL Containers can be imported using the resourceId
, e.g.