How do I connect to a Spinup DocumentDB database?

Objective

Connect to a DocumentDB instance that has been created on Spinup.

Introduction

Spinup offers a service around DocumentDB, a NoSQL document database provided by Amazon Web Services (AWS), that is designed to be compatible with MongoDB. In this guide, you will learn how to connect with you DocumentDB instance after having created it on Spinup. There are several options to connect, including the Studio3T graphical user interface (GUI), or through command-line interface (CLI) via a linux server.


  1. Download and install Studio3T

  2. Click 'Connect' at the top, then click 'New connection'. Choose Manually configure my connection settings

     

     

  3. Under the 'Server' tab, fill out the Connection name. Choose Standalone as the 'Connection Type'. Copy the endpoint from the details page of your DocumentDB and fill it out next to Server.

     

  4. Under the 'Authentication' tab, choose Legacy (SCRAM-SHA-1) as the 'Authentication Mode'. Fill out the User name and Password from when you created the DocumentDB. Use a custom database name for the Authentication DB field (admin does not work for Amazon DocumentDB clusters with no databases. Once you have created your first database you can modify your connection to use admin, if you wish.)

  5. Download this new CA certificate from AWS. Under the 'SSL' tab, choose Use SSL protocol to connect' Then, select the Use own Root CA file (–sslCAFile) option and browse to the rds-combined-ca-bundle.pem certificate file that was just downloaded using the folder icon on the right.

  1. Navigate back to Spinup, and under the 'Firewall' tab on your Space's home page, add Port 27017 as an inbound rule. Choose Other (custom) as the 'Service', 27017 as the 'Port', and select Anywhere for the 'Source IP subnet' (for further information: How do I use the Firewall in Spinup Spaces?)

  2. In Studio3T, in the 'New Connection' window, click Test Connection on the bottom left. If the test succeeds, you can Save your new connection, and under the 'Connection Manager' window, you can Connect with the DocumentDB (should be under Local Resources).

If your connection does not succeed, check to make sure you are on the Yale network (either on-campus or via VPN).

In order to connect to the DocumentDB, you need to install the MongoDB Shell. Instructions to install the MongoDB shell vary depending on your distribution. In the example shown below, I will the steps I followed using an Ubuntu 22.04 instance created on Spinup.

  1. Follow the instructions for your computer on the MongoDB website to install the MongoDB Shell. These are the commands I ran for Ubuntu 22.04:

    wget -qO- https://www.mongodb.org/static/pgp/server-7.0.asc | sudo tee /etc/apt/trusted.gpg.d/server-7.0.asc echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list sudo apt-get update sudo apt-get install -y mongodb-mongosh

Run the following command to confirm that mongosh installed successfully: mongosh --version

  1. Download the CA certificate from AWS.

    wget https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
  2. Navigate back to Spinup, and under the 'Firewall' tab on your Space's home page, add Port 27017 as an inbound rule. Choose Other (custom) as the 'Service', 27017 as the 'Port', and select Anywhere for the 'Source IP subnet' (for further information: How do I use the Firewall in Spinup Spaces?)

  1. Follow the instructions to connect to a deployment on a remote host. Copy the endpoint from the details page of your DocumentDB.

mongosh -tls <cluster endpoint>:27017 --username <username> --tlsCAFile rds-combined-ca-bundle.pem # Example # mongosh -tls spinup-docdb00245c.cluster-c9ukc6s0rmbg.us-east-1.docdb.amazonaws.com:27017 --username test1234 --tlsCAFile rds-combined-ca-bundle.pem