I had a similar problem (probably technically a duplicate question), and I opted to connect via Cloud9. Here is an excerpt of my answer there.
When setting up Cloud9, for some reason I had to select the "Secure Shell (SSH)" connection option, as the "AWS Systems Manager (SSM)" would give me an error with a lifecycle status of "Creation failed".
You can use the Cloud9 terminal to install the MongoDB shell and then use it to connect to your DocumentDB cluster in the same VPC. See Get Started with Amazon DocumentDB for an overview. Here are some tips from my experiences.
You can get the connection instructions from the console page for your DocumentDB cluster under "Connectivity & security". It assumes you've already installed the MongoDB shell, and assumes you're using the old version mongo
. I preferred to use the newer mongosh
, even though DocumentDB isn't compatible with the latest MongoDB versions, if nothing else than to ensure that the simple functionality I needed works with DocumentDB. So I followed the official MongoDB installation instructions, being sure to select "Amazon Linux".
Rather than typing some echo
instructions, I typed sudo nano /etc/yum.repos.d/mongodb-org-6.0.repo
and entered the following information to set up the latest (as of today) MongoDB Yum RPM repo:
[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc
Then installed mongosh
:
sudo yum install -y mongodb-mongosh
Then finally I followed the connections instructions for my DocumentDB cluster from the console.
wget https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
mongosh --tls --host <cluster-info>.us-east-1.docdb.amazonaws.com:27017 --tlsCAFile rds-combined-ca-bundle.pem --username <username> --password <password>
Note that using the latest mongosh
(v1.8.0), besides using mongo
instead of mongosh
it's best to also:
- use
--tls
instead of --ssl
, and
- use
--tlsCAFile
instead of --sslCAFile
.