Skip to content

Commit ea2f78e

Browse files
committed
add information about connection string
1 parent 11a256b commit ea2f78e

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

docs/concepts/managed-storage/managed-mongodb.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,7 @@ If you do not provide these values, the deployment will fail.
4343

4444
When using managed MongoDB on GCP, you **must** set a `MONGO_INITDB_DATABASE` environment variable with the name of the database to create.
4545

46-
```yaml
47-
services:
48-
db:
49-
x-defang-mongodb: true
50-
environment:
51-
MONGO_INITDB_DATABASE: mydb
52-
```
46+
Defang will automatically create a config variable named `<SERVICE_NAME>_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`.
5347

5448
**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.
5549

@@ -60,7 +54,7 @@ services:
6054
app:
6155
# [...]
6256
environment:
63-
MONGO_URI: mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@db:27017/
57+
DB_URL: mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@db:27017/
6458
depends_on:
6559
- db
6660

0 commit comments

Comments
 (0)