Azure CosmosDB (DocumentDB) Mongo Collection - Examples and best practices | Shisho Dojo (2024)

This page shows how to write Terraform and Azure Resource Manager for CosmosDB (DocumentDB) Mongo Collection and write them securely.

azurerm_cosmosdb_mongo_collection (Terraform)

The Mongo Collection in CosmosDB (DocumentDB) can be configured in Terraform with the resource name azurerm_cosmosdb_mongo_collection. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

azure.tf#L72

resource "azurerm_cosmosdb_mongo_collection" "ngc" { name = "Sessions" resource_group_name = azurerm_resource_group.ngc.name account_name = azurerm_cosmosdb_account.ngc.name database_name = azurerm_cosmosdb_mongo_database.ngc_sessions.name

Find out how to use this setting securely with Shisho Cloud

cosmosdb-mongodb-collection.tf#L4

resource "azurerm_cosmosdb_mongo_collection" "mongo_collection_static" { name = var.collection_name resource_group_name = var.resource_group_name account_name = var.account_name database_name = var.db_name default_ttl_seconds = var.default_ttl_seconds

Find out how to use this setting securely with Shisho Cloud

cosmosdb_mongo_collection_test.tf#L122

resource "azurerm_cosmosdb_mongo_collection" "non-usage_autoscale" { name = "tfex-cosmos-mongo-db" resource_group_name = azurerm_cosmosdb_account.example.resource_group_name account_name = azurerm_cosmosdb_account.example.name database_name = azurerm_cosmosdb_mongo_database.non-usage_autoscale.name

Find out how to use this setting securely with Shisho Cloud

cosmosdb_mongo_collection_test.tf#L122

resource "azurerm_cosmosdb_mongo_collection" "non-usage_autoscale" { name = "tfex-cosmos-mongo-db" resource_group_name = azurerm_cosmosdb_account.example.resource_group_name account_name = azurerm_cosmosdb_account.example.name database_name = azurerm_cosmosdb_mongo_database.non-usage_autoscale.name

Find out how to use this setting securely with Shisho Cloud

main.tf#L60

resource "azurerm_cosmosdb_mongo_collection" "questions" { name = "questions" resource_group_name = azurerm_resource_group.rg.name account_name = azurerm_cosmosdb_account.default.name database_name = azurerm_cosmosdb_mongo_database.default.name

Find out how to use this setting securely with Shisho Cloud

mongo_collection.tf#L2

resource "azurerm_cosmosdb_mongo_collection" "collection" { name = var.settings.name resource_group_name = var.resource_group_name account_name = var.cosmosdb_account_name database_name = var.database_name shard_key = var.settings.shard_key

Find out how to use this setting securely with Shisho Cloud

cosmos-db-mongo-collection.tf#L1

resource "azurerm_cosmosdb_mongo_collection" "event_collection" { name = "events" resource_group_name = azurerm_resource_group.rg.name account_name = azurerm_cosmosdb_account.db_account.name database_name = azurerm_cosmosdb_mongo_database.mongo_db.name

Find out how to use this setting securely with Shisho Cloud

mongo_collection.tf#L2

resource "azurerm_cosmosdb_mongo_collection" "collection" { name = var.settings.name resource_group_name = var.resource_group_name account_name = var.cosmosdb_account_name database_name = var.database_name shard_key = var.settings.shard_key

Find out how to use this setting securely with Shisho Cloud

mongo_collection.tf#L2

resource "azurerm_cosmosdb_mongo_collection" "collection" { name = var.settings.name resource_group_name = var.resource_group_name account_name = var.cosmosdb_account_name database_name = var.database_name shard_key = var.settings.shard_key

Find out how to use this setting securely with Shisho Cloud

main.tf#L24

resource "azurerm_cosmosdb_mongo_collection" "mongodb" { count = length(var.collections) name = var.collections[count.index].name default_ttl_seconds = var.collections[count.index].default_ttl_seconds

Find out how to use this setting securely with Shisho Cloud

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages a Mongo Collection within a Cosmos DB Account.

Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections (Azure Resource Manager)

The databaseAccounts/mongodbDatabases/collections in Microsoft.DocumentDB can be configured in Azure Resource Manager with the resource name Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections. 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 - string
  • location optional - string

    The location of the resource group to which the resource belongs.

  • name required - string

    Cosmos DB collection name.

  • properties required
      • options optional
          • autoscaleSettings optional
              • maxThroughput optional - integer

                Represents maximum throughput, the resource can scale up to.

          • throughput optional - integer

            Request Units per second. For example, "throughput": 10000.

      • resource required
          • analyticalStorageTtl optional - integer

            Analytical TTL.

          • id required - string

            Name of the Cosmos DB MongoDB collection

          • indexes optional array
              • key optional
                  • keys optional - array

                    List of keys for each MongoDB collection in the Azure Cosmos DB service

              • options optional
                  • expireAfterSeconds optional - integer

                    Expire after seconds

                  • unique optional - boolean

                    Is unique or not

          • shardKey optional - string

            The shard key and partition kind pair, only support "Hash" partition kind

  • tags optional - string

    Tags 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 Collection?

Azure CosmosDB (DocumentDB) Mongo Collection 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 Collection?

For Terraform, the cloud-native-conference/Infrastructure, marvin-heiden/sendungsverfolgung and gilyas/infracost source code examples are useful. See the Terraform Example section for further details.

Azure CosmosDB (DocumentDB) Mongo Collection - Examples and best practices | Shisho Dojo (2024)
Top Articles
Magic: The Gathering Arena
Best Kodi Anime Addon
How To Be A Reseller: Heather Hooks Is Hooked On Pickin’ - Seeking Connection: Life Is Like A Crossword Puzzle
360 Training Alcohol Final Exam Answers
RuneScape guide: Capsarius soul farming made easy
Naturalization Ceremonies Can I Pick Up Citizenship Certificate Before Ceremony
Green Bay Press Gazette Obituary
Was sind ACH-Routingnummern? | Stripe
FIX: Spacebar, Enter, or Backspace Not Working
Vichatter Gifs
Conduent Connect Feps Login
Mens Standard 7 Inch Printed Chappy Swim Trunks, Sardines Peachy
Alejos Hut Henderson Tx
Used Drum Kits Ebay
Unit 33 Quiz Listening Comprehension
979-200-6466
Busby, FM - Demu 1-3 - The Demu Trilogy - PDF Free Download
Canvas Nthurston
Directions To Advance Auto
Farmer's Almanac 2 Month Free Forecast
TBM 910 | Turboprop Aircraft - DAHER TBM 960, TBM 910
Pickswise Review 2024: Is Pickswise a Trusted Tipster?
Military life insurance and survivor benefits | USAGov
Walgreens Bunce Rd
Bolsa Feels Bad For Sancho's Loss.
Panolian Batesville Ms Obituaries 2022
Motorcycle Blue Book Value Honda
Tomb Of The Mask Unblocked Games World
Himekishi Ga Classmate Raw
Downloahub
R/Mp5
Planned re-opening of Interchange welcomed - but questions still remain
Learn4Good Job Posting
Red Sox Starting Pitcher Tonight
Grand Teton Pellet Stove Control Board
Fandango Pocatello
Ixlggusd
Roch Hodech Nissan 2023
Despacito Justin Bieber Lyrics
Troy Gamefarm Prices
ENDOCRINOLOGY-PSR in Lewes, DE for Beebe Healthcare
Merkantilismus – Staatslexikon
Xxn Abbreviation List 2023
Former Employees
Access to Delta Websites for Retirees
Grace Family Church Land O Lakes
Round Yellow Adderall
Suzanne Olsen Swift River
Att Corporate Store Location
Varsity Competition Results 2022
Latest Posts
Article information

Author: Jeremiah Abshire

Last Updated:

Views: 6490

Rating: 4.3 / 5 (54 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Jeremiah Abshire

Birthday: 1993-09-14

Address: Apt. 425 92748 Jannie Centers, Port Nikitaville, VT 82110

Phone: +8096210939894

Job: Lead Healthcare Manager

Hobby: Watching movies, Watching movies, Knapping, LARPing, Coffee roasting, Lacemaking, Gaming

Introduction: My name is Jeremiah Abshire, I am a outstanding, kind, clever, hilarious, curious, hilarious, outstanding person who loves writing and wants to share my knowledge and understanding with you.