Azure CosmosDB (DocumentDB) Mongo Database
This page shows how to write Terraform and Azure Resource Manager for CosmosDB (DocumentDB) Mongo Database and write them securely.
azurerm_cosmosdb_mongo_database (Terraform)
The Mongo Database in CosmosDB (DocumentDB) can be configured in Terraform with the resource name azurerm_cosmosdb_mongo_database
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_cosmosdb_mongo_database" "mydb" {
name = "mydb"
resource_group_name = data.azurerm_resource_group.GymResourceGroup.name
account_name = azurerm_cosmosdb_account.gym_cosmos_account.name
throughput = 400
}
resource "azurerm_cosmosdb_mongo_database" "ngc_sessions" {
name = "SessionsDb"
resource_group_name = azurerm_resource_group.ngc.name
account_name = azurerm_cosmosdb_account.ngc.name
}
resource "azurerm_cosmosdb_mongo_database" "non-usage_autoscale" {
name = "tfex-cosmos-cassandra-keyspace"
resource_group_name = azurerm_cosmosdb_account.example.resource_group_name
account_name = azurerm_cosmosdb_account.example.name
autoscale_settings {
max_throughput = 4000
resource "azurerm_cosmosdb_mongo_database" "non-usage_autoscale" {
name = "tfex-cosmos-cassandra-keyspace"
resource_group_name = azurerm_cosmosdb_account.example.resource_group_name
account_name = azurerm_cosmosdb_account.example.name
autoscale_settings {
max_throughput = 4000
resource "azurerm_cosmosdb_mongo_database" "non-usage_autoscale" {
name = "tfex-cosmos-cassandra-keyspace"
resource_group_name = azurerm_cosmosdb_account.example.resource_group_name
account_name = azurerm_cosmosdb_account.example.name
autoscale_settings {
max_throughput = 4000
resource "azurerm_cosmosdb_mongo_database" "non-usage_autoscale" {
name = "tfex-cosmos-cassandra-keyspace"
resource_group_name = azurerm_cosmosdb_account.example.resource_group_name
account_name = azurerm_cosmosdb_account.example.name
autoscale_settings {
max_throughput = 4000
resource "azurerm_cosmosdb_mongo_database" "post-office-mongo-db" {
name = "mongo-db"
location = azurerm_resource_group.post-office-rg.location
resource_group_name = azurerm_resource_group.post-office-rg.name
throughput = 400
}
resource "azurerm_cosmosdb_mongo_database" "this" {
account_name = var.account_name
name = var.name
resource_group_name = var.resource_group_name
throughput = var.throughput
resource "azurerm_cosmosdb_mongo_database" "mongodb" {
name = "cosmosmongodb"
resource_group_name = azurerm_cosmosdb_account.acc.resource_group_name
account_name = azurerm_cosmosdb_account.acc.name
throughput = 400
}
resource "azurerm_cosmosdb_mongo_database" "database" {
name = var.settings.name
resource_group_name = var.resource_group_name
account_name = var.cosmosdb_account_name
throughput = try(var.settings.throughput, null)
Parameters
-
account_name
required - string -
id
optional computed - string -
name
required - string -
resource_group_name
required - string -
throughput
optional computed - number -
autoscale_settings
list block-
max_throughput
optional computed - number
-
-
timeouts
single block
Explanation in Terraform Registry
Manages a Mongo Database within a Cosmos DB Account.
Microsoft.DocumentDB/databaseAccounts/mongodbDatabases (Azure Resource Manager)
The databaseAccounts/mongodbDatabases in Microsoft.DocumentDB can be configured in Azure Resource Manager with the resource name Microsoft.DocumentDB/databaseAccounts/mongodbDatabases
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
apiVersion
required - stringlocation
optional - stringThe location of the resource group to which the resource belongs.
name
required - stringCosmos DB database name.
properties
requiredoptions
optionalautoscaleSettings
optionalmaxThroughput
optional - integerRepresents maximum throughput, the resource can scale up to.
throughput
optional - integerRequest Units per second. For example, "throughput": 10000.
resource
requiredid
required - stringName of the Cosmos DB MongoDB database
tags
optional - stringTags are a list of key-value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters. For example, the default experience for a template type is set with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", "Graph", "DocumentDB", and "MongoDB".
type
required - string
Frequently asked questions
What is Azure CosmosDB (DocumentDB) Mongo Database?
Azure CosmosDB (DocumentDB) Mongo Database is a resource for CosmosDB (DocumentDB) of Microsoft Azure. Settings can be wrote in Terraform.
Where can I find the example code for the Azure CosmosDB (DocumentDB) Mongo Database?
For Terraform, the TELLAI/Gym-project-MERN, cloud-native-conference/Infrastructure and gilyas/infracost source code examples are useful. See the Terraform Example section for further details.