You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/aws/services/docdb.md
+72-74Lines changed: 72 additions & 74 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
---
2
2
title: "DocumentDB (DocDB)"
3
-
linkTitle: "DocumentDB (DocDB)"
4
3
tags: ["Ultimate"]
5
4
description: Get started with AWS DocumentDB on LocalStack
6
5
---
@@ -11,17 +10,19 @@ DocumentDB is a fully managed, non-relational database service that supports Mon
11
10
DocumentDB is compatible with MongoDB, meaning you can use the same MongoDB drivers, applications, and tools to run, manage, and scale workloads on DocumentDB without having to worry about managing the underlying infrastructure.
12
11
13
12
LocalStack allows you to use the DocumentDB APIs to create and manage DocumentDB clusters and instances.
14
-
The supported APIs are available on our [API coverage page]({{< ref "coverage_docdb" >}}), which provides information on the extent of DocumentDB's integration with LocalStack.
13
+
The supported APIs are available on our [API coverage page](), which provides information on the extent of DocumentDB's integration with LocalStack.
15
14
16
15
## Getting started
17
16
18
17
To create a new DocumentDB cluster we use the `create-db-cluster` command as follows:
As we did not specify a `MasterUsername` or `MasterUserPassword` for the creation of the database, the mongo-db will not set any credentials when starting the docker container.
64
65
To create a new database, we can use the `create-db-instance` command, like in this example:
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
193
-
194
-
------
195
-
test-company>
196
-
197
-
{{< /command >}}
191
+
```bash
192
+
mongosh mongodb://localhost:39045/test-company
193
+
```
198
194
199
195
From here on we can manipulate collections
200
196
using [the JavaScript methods provided](https://www.mongodb.com/docs/manual/reference/method/)
201
197
by `mongosh`:
202
198
203
-
{{< command >}}
204
-
199
+
```bash
205
200
test-company> db.createCollection("employees")
206
201
{ ok: 1 }
207
202
test-company> db.createCollection("customers")
@@ -210,20 +205,19 @@ test-company> show collections
210
205
customers
211
206
employees
212
207
test-company>exit
213
-
214
-
{{< /command >}}
208
+
```
215
209
216
210
For more information on how to use MongoDB with `mongosh` please refer to
217
211
the [MongoDB documentation](https://www.mongodb.com/docs/).
218
212
219
213
### Connect to DocumentDB using Node.js Lambda
220
214
221
-
{{< callout >}}
215
+
:::note
222
216
You need to set`DOCDB_PROXY_CONTAINER=1` when starting LocalStack to be able to use the returned `Endpoint`, which will be correctly resolved automatically.
223
217
224
218
The flag `DOCDB_PROXY_CONTAINER=1` changes the default behavior and the container will be started as proxied container.
225
-
Meaning a port from the [pre-defined port]({{< ref "/references/external-ports" >}}) range will be chosen, and when using lambda, you can use `localhost.localstack.cloud` to connect to the instance.
226
-
{{< /callout >}}
219
+
Meaning a port from the [pre-defined port]() range will be chosen, and when using lambda, you can use `localhost.localstack.cloud` to connect to the instance.
220
+
:::
227
221
228
222
In this sample we will use a Node.js lambda functionto connect to a DocumentDB.
229
223
For the mongo-db connection we will use the `mongodb` lib.
@@ -235,29 +229,31 @@ We included a snippet at the very end.
235
229
#### Create the DocDB Cluster with a username and password
236
230
237
231
We assume you have a `MasterUsername` and `MasterUserPassword`setfor DocDB e.g:
The LocalStack Web Application provides a Resource Browser for managing DocumentDB instances and clusters.
399
399
You can access the Resource Browser by opening the LocalStack Web Application in your browser, navigating to the **Resources** section, and then clicking on **DocumentDB** under the **Database** section.
0 commit comments