Lambda can connect to a DocumentDB Cluster:
- Connection Types:
- read-write - Lambda can read from the DB and write to the DB.
- read-only - Lambda can only read from the DB.
After adding the connection, you can see generated environment variables that are now accessible for the Lambdas:
You'll need to use these variables in your code to connect to MongoDB:
- DOC_DB_DOCUMENTDB01 - the endpoint of the cluster (host and port).
- DB_SECRET_DOCUMENTDB01 - the secret IDs of user name and password of the cluster.
When we added the connection, we got the following recommendation:
- Follow the recommendation in order to gain access to the DB - make sure that the Lambda Function and the Document DB Cluster are in the same VPC.