Edit

Share via


Azure Cosmos DB for MongoDB (vCore) with Terraform

This document provides instructions on using Terraform to deploy Azure Cosmos DB for MongoDB vCore resources. This process involves directly calling the ARM API through Terraform.

Prerequisites

  • Terraform installed on your machine.
  • An Azure subscription.

Terraform Configuration

Create a new *.tf file in your Terraform project directory. Copy the example code and replace the resource group placeholder values with your own:

resource "azurerm_resource_group" "example" {
  name     = "example-rg"
  location = "East US"
}

resource "azurerm_mongo_cluster" "example" {
  name                   = "example-mc"
  resource_group_name    = azurerm_resource_group.example.name
  location               = azurerm_resource_group.example.location
  administrator_username = "adminTerraform"
  administrator_password = "QAZwsx123"
  shard_count            = "1"
  compute_tier           = "Free"
  high_availability_mode = "Disabled"
  storage_size_in_gb     = "32"
}

For a complete list of parameters, including required and optional arguments, visit the official Terraform Registry documentation.

Next steps