Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions docs/concepts/managed-storage/managed-mongodb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: Managed MongoDB
description: Defang can help you provision managed MongoDB instances.
sidebar_position: 3000
---

# Managed MongoDB

:::info
This feature was introduced in Defang v1.2.0 released on June 3, 2025.
:::

Managed MongoDB is a service that allows you to store and retrieve large amounts of data in a document-oriented format. MongoDB is ideal for storing unstructured data like JSON documents, making it a popular choice for modern applications.

## Current Support

| Provider | Managed MongoDB |
| --- | --- |
| [Playground](/docs/providers/playground#managed-services) | ❌ |
| [AWS](/docs/providers/aws#managed-storage) | ✅ |
| [DigitalOcean](/docs/providers/digitalocean#future-improvements) | ❌ |
| [GCP](/docs/providers/gcp#future-improvements) | ❌ |

## How to use Managed MongoDB

To use managed MongoDB, in your `compose.yaml` file, use the `x-defang-mongodb` extension to define your MongoDB service. Adding the extension will tell Defang to provision a managed instance, rather than running MongoDB as a container.

### Required Configuration

When using managed MongoDB, you **must** set a username and password for the database. By default, these are read from the `MONGO_INITDB_ROOT_USERNAME` and `MONGO_INITDB_ROOT_PASSWORD` config variables, conform [the official MongoDB container image](https://hub.docker.com/_/mongo). These can be set using the `defang config set MONGO_INITDB_ROOT_USERNAME` and `defang config set MONGO_INITDB_ROOT_PASSWORD` commands. If you do not provide these values, the deployment will fail.

### Example

```yaml
services:
app:
# [...]
environment:
MONGO_URI: mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@db:27017/
depends_on:
- db

db:
image: mongo:5
x-defang-mongodb: true
```

:::warning[Version]
AWS DocumentDB is compatible with MongoDB 3.6, 4.0, and 5.0. The `mongo:5` image is compatible with DocumentDB 5.0, so we recommend using this version for your MongoDB service. Deployment will fail for versions higher than 5.
:::
4 changes: 4 additions & 0 deletions docs/providers/aws/aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ Defang offers integration with managed, cloud-native large language model servic

When using [Managed LLMs](/docs/concepts/managed-llms/managed-language-models.md), the Defang CLI provisions an ElastiCache Redis cluster in your account.

### Managed MongoDB

Defang will provision a DocumentDB instance for services that use the `x-defang-mongodb` service extension. This allows you to use MongoDB as a managed service, rather than running it as a container.

### Managed Resources

Defang will create and manage the following resources in your AWS account from its bootstrap CloudFormation template:
Expand Down