diff --git a/docs/concepts/managed-storage/managed-mongodb.md b/docs/concepts/managed-storage/managed-mongodb.md index c30d2f892d..59d370f7cd 100644 --- a/docs/concepts/managed-storage/managed-mongodb.md +++ b/docs/concepts/managed-storage/managed-mongodb.md @@ -7,7 +7,7 @@ sidebar_position: 3000 # Managed MongoDB :::info -This feature was introduced in Defang v1.2.0 released on June 3, 2025. [Upgrade to the latest version](/docs/cli/defang_upgrade) +This feature was introduced in Defang v1.2.0 released on June 3, 2025 for AWS. [Upgrade to the latest version](/docs/cli/defang_upgrade) ::: 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. @@ -19,7 +19,7 @@ Managed MongoDB is a service that allows you to store and retrieve large amounts | [Playground](/docs/providers/playground#managed-services) | ⚠️ Unmanaged | | [AWS](/docs/providers/aws#managed-storage) | ✅ DocumentDB | | [DigitalOcean](/docs/providers/digitalocean#future-improvements) | ⚠️ Unmanaged | -| [GCP](/docs/providers/gcp#future-improvements) | ⚠️ Unmanaged | +| [GCP](/docs/providers/gcp#future-improvements) | ✅ Firestore | ## How to use Managed MongoDB @@ -27,7 +27,25 @@ To use managed MongoDB, in your `compose.yaml` file, use the `x-defang-mongodb` ### 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. +### AWS +When using managed MongoDB on AWS, 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, following [the official MongoDB container image](https://hub.docker.com/_/mongo) convention. + +You can set these using the following commands: + +```bash +defang config set MONGO_INITDB_ROOT_USERNAME +defang config set MONGO_INITDB_ROOT_PASSWORD +``` + +If you do not provide these values, the deployment will fail. + +### GCP + +When using managed MongoDB on GCP, you **must** set a `MONGO_INITDB_DATABASE` environment variable with the name of the database to create. + +Defang will automatically create a config variable named `_URL` that contains the connection string for your MongoDB database. For example, if your service is named `db`, the config variable will be `DB_URL`. + +**Important:** GCP will ignore `MONGO_INITDB_ROOT_USERNAME` and `MONGO_INITDB_ROOT_PASSWORD` credentials since they are not needed. GCP automatically handles authentication and grants your service access to the MongoDB database. ### Example @@ -36,15 +54,23 @@ services: app: # [...] environment: - MONGO_URI: mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@db:27017/ + DB_URL: mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@db:27017/ depends_on: - db db: image: mongo:5 x-defang-mongodb: true + environment: + MONGO_INITDB_DATABASE: mydb ``` +:::warning[Deleting a GCP Firestore MongoDB Database] +Please be aware that GCP Firestore does not allow deletion of your database when you bring down your project using `defang compose down`. You must go to the [GCP Cloud Console for Firestore](https://console.cloud.google.com/firestore/databases/) to delete it manually. +::: + :::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. + +GCP Firestore does not have a configurable version. ::: diff --git a/docs/concepts/managed-storage/managed-storage.md b/docs/concepts/managed-storage/managed-storage.md index 1b5b0c23c0..534c13cf2a 100644 --- a/docs/concepts/managed-storage/managed-storage.md +++ b/docs/concepts/managed-storage/managed-storage.md @@ -6,4 +6,4 @@ sidebar_position: 000 # Managed Storage -Defang helps you provision the infrastructure you need to run your services. That infrastructure is designed to scale in and out without persistent storage, so you can build highly scalable services. But Defang can also help you provision managed services to store and persist your data, like [caches](./managed-redis.md), [databases](./managed-postgres.mdx), and [object storage](./managed-object-storage.md). +Defang helps you provision the infrastructure you need to run your services. That infrastructure is designed to scale in and out without persistent storage, so you can build highly scalable services. Defang can also help you provision managed services to store and persist your data, like [caches](./managed-redis.md), [sql databases](./managed-postgres.mdx), [nosql databases](./managed-mongodb.md), and [object storage](./managed-object-storage.md).