azurerm_cosmosdb_sql_container

Manages a SQL Container within a Cosmos DB Account.

Example Usage

data "azurerm_cosmosdb_account" "example" {
  name                = "tfex-cosmosdb-account"
  resource_group_name = "tfex-cosmosdb-account-rg"
}

resource "azurerm_cosmosdb_sql_database" "example" {
  name                = "example-acsd"
  resource_group_name = data.azurerm_cosmosdb_account.example.resource_group_name
  account_name        = data.azurerm_cosmosdb_account.example.name
}

resource "azurerm_cosmosdb_sql_container" "example" {
  name                  = "example-container"
  resource_group_name   = data.azurerm_cosmosdb_account.example.resource_group_name
  account_name          = data.azurerm_cosmosdb_account.example.name
  database_name         = azurerm_cosmosdb_sql_database.example.name
  partition_key_path    = "/definition/id"
  partition_key_version = 1
  throughput            = 400

  indexing_policy {
    indexing_mode = "consistent"

    included_path {
      path = "/*"
    }

    included_path {
      path = "/included/?"
    }

    excluded_path {
      path = "/excluded/?"
    }
  }

  unique_key {
    paths = ["/definition/idlong", "/definition/idshort"]
  }
}

Argument Reference

The following arguments are supported:


An autoscale_settings block supports the following:


A unique_key block supports the following:


An indexing_policy block supports the following:


A spatial_index block supports the following:


An included_path block supports the following:


An excluded_path block supports the following:


A composite_index block supports the following:


An index block supports the following:


A conflict_resolution_policy block supports the following:

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:


A spatial_index block exports the following:

Timeouts

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

Import

Cosmos SQL Containers can be imported using the resource id, e.g.

terraform import azurerm_cosmosdb_sql_container.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1