Installing Mongo Shell

Mongo shell is the command-line utility that you use to connect and perform query and admin operations on your Amazon DocumentDB cluster.

To install mongo shell, navigate to AWS cloud9 management Console and choose open IDE to launch AWS Cloud9 environment. You can close the Welcome screen and adjust your terminal to increase screen area.

You’ll now create the repository file. Copy the below line of code and paste in your AWS Cloud9 command prompt.

echo -e "[mongodb-org-4.0] \nname=MongoDB Repository\nbaseurl=\ngpgcheck=1 \nenabled=1 \ngpgkey=" | sudo tee /etc/yum.repos.d/mongodb-org-4.0.repo

After creating the repository, install mongo shell using the below

sudo yum install -y mongodb-org-shell

Amazon DocumentDB clusters have TLS enabled by default. For more information, refer Managing Amazon DocumentDB Cluster TLS Settings. Amazon DocumentDB defaults are configured to adhere to security best practices.

Download the CA certificate for Amazon DocumentDB to encrypt data in transit as follows.


Connecting to Amazon Document DB Cluster

Verify that the Amazon DocumentDB cluster is created by checking the status of the instance under Instances menu of the Amazon DocumentDB console. You’ll now connect to our cluster from the Cloud Environment. Navigate to Amazon Document DB console and locate your cluster using the cluster identifier getting-started-with-documentdb.

Amazon DocumentDB Console Select

Click on the cluster identifier link and copy the connection string for your cluster.

Amazon DocumentDB Connection String Copy

You can omit the <insertYourPassword> text and paste the connecting string on your Cloud9 envrinment. Enter the password for Amazon DocumentDB cluster.

Amazon Cloud9 Connection String

The Cloud9 envrionment is now connected to the Amazon DocumentDB cluster and you should see the rs0:PRIMARY indicating that you have successfully connected to Amazon DocumentDB. If you are having trouble connecting, you may refer Troubleshooting Amazon DocumentDB for help.