Skip to content

Commit b656e9a

Browse files
fix(mdb): exemples connection string vpc
1 parent a79154c commit b656e9a

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

pages/managed-mongodb-databases/how-to/connect-database-instance.mdx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ content:
77
paragraph: This page explains how to connect to a MongoDB® Database Instance
88
tags: mongodb mongodb document database-instance managed-database database
99
dates:
10-
validation: 2024-09-18
10+
validation: 2024-02-17
1111
posted: 2024-09-18
1212
categories:
1313
- managed-databases
@@ -38,7 +38,7 @@ Managed MongoDB® is currently in public beta. Click [here](https://www.scaleway
3838

3939
Find below a detailed description of each connection mode:
4040

41-
### mongosh
41+
### With mongosh
4242

4343
To connect to a public endpoint using the MongoDB® shell:
4444

@@ -67,19 +67,11 @@ If the connection is successful, you should see the following message display on
6767
rs-{db-instance-id} [primary] test>
6868
```
6969

70-
Follow the same procedure to connect to a private endpoint for one node, replacing `{privateNetworkId}` with the `ID` of your Private Network:
71-
72-
```sh
73-
mongosh "mongodb://{db-instance-id}-0.{privateNetworkId}" -u {username} --tlsCAFile {your_certificate.pem}
74-
```
75-
76-
For multiple nodes, replace `{db-instance-id}` with the Database Instance UUID of each respective Instance, and `{privateNetworkId}` with the `ID` of your Private Network:
77-
78-
```sh
79-
"mongodb://{db-instance-id}-0.{privateNetworkId},{db-instance-id}-1.{privateNetworkId},{db-instance-id}-2.{privateNetworkId}" -u {username} --tlsCAFile {your_certificate.pem}
80-
```
70+
<Message type="important">
71+
To connect to a MongoDB® via a Private Network, use the following command: `mongosh "mongodb+srv://{username}:{password}@{instance_id}.{private_network_id}.internal/?tls=true&tlsCAFile={tls_certificate}"`. Make sure you replace the variables indicated within the `{}` with their corresponding values.
72+
</Message>
8173

82-
### Python
74+
### With Pymongo
8375

8476
The following code shows you how to use the `pymongo` library to connect using TLS.
8577

@@ -115,8 +107,11 @@ documents = collection.find({})
115107
for doc in documents:
116108
print(doc)
117109
```
110+
<Message type="important">
111+
To connect to a MongoDB® via a Private Network, use the following connection string: `connection_string = f"mongodb+srv://{username}:{password}@{instance_id}.{private_network_id}.internal/?tls=true&tlsCAFile={tls_certificate}"`. Make sure you replace the variables indicated within the `{}` with their corresponding values.
112+
</Message>
118113

119-
### Node.js
114+
### With Node.js
120115

121116
The following code shows you how to use the `mongodb` module to connect using TLS.
122117

@@ -170,7 +165,7 @@ async function run() {
170165
run().catch(console.dir);
171166
```
172167

173-
### Go
168+
### With Go
174169

175170
The following code shows you how to use the `mongo` driver to connect using TLS.
176171
```go
@@ -225,7 +220,7 @@ type Car struct {
225220
}
226221
```
227222

228-
### Mongoose
223+
### With Mongoose
229224

230225
The following code shows you how to use the `Mongoose` schema to connect using TLS.
231226

0 commit comments

Comments
 (0)