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
+74-74Lines changed: 74 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,21 @@ 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
67
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 >}}
193
+
```bash
194
+
mongosh mongodb://localhost:39045/test-company
195
+
```
198
196
199
197
From here on we can manipulate collections
200
198
using [the JavaScript methods provided](https://www.mongodb.com/docs/manual/reference/method/)
201
199
by `mongosh`:
202
200
203
-
{{< command >}}
204
-
201
+
```bash
205
202
test-company> db.createCollection("employees")
206
203
{ ok: 1 }
207
204
test-company> db.createCollection("customers")
@@ -210,20 +207,19 @@ test-company> show collections
210
207
customers
211
208
employees
212
209
test-company>exit
213
-
214
-
{{< /command >}}
210
+
```
215
211
216
212
For more information on how to use MongoDB with `mongosh` please refer to
217
213
the [MongoDB documentation](https://www.mongodb.com/docs/).
218
214
219
215
### Connect to DocumentDB using Node.js Lambda
220
216
221
-
{{< callout >}}
217
+
:::note
222
218
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
219
224
220
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 >}}
221
+
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.
222
+
:::
227
223
228
224
In this sample we will use a Node.js lambda functionto connect to a DocumentDB.
229
225
For the mongo-db connection we will use the `mongodb` lib.
@@ -235,29 +231,31 @@ We included a snippet at the very end.
235
231
#### Create the DocDB Cluster with a username and password
236
232
237
233
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
401
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