I’m trying to migrate from MongoDB to DocumentDB just for keeping everything under one roof, and I want to test my code on a sample DocDB cluster. I’m using Node.js + Express.js for my backend. However, it’s been proving quite difficult with the mental jumps and hoops I’m going through.
The instructions provided by the AWS DocumentDB documentation for connecting from outside the VPC have been extraordinarily unhelpful.
In fact, they may even be considered dangerous:
To connect to your Amazon DocumentDB cluster from outside the Amazon VPC, use the following command.
mongo --sslAllowInvalidHostnames --ssl --sslCAFile global-bundle.pem --username <yourUsername> --password <yourPassword>
sslAllowInvalidHostnames
seems like it’s used for preventing localhost
from being rejected due to not match the IP hosts, as seen below when it’s forcibly disabled:
MongoServerSelectionError: Hostname/IP does not match certificate's altnames: Host: localhost. is not in the cert's altnames: DNS:sldkfjl.ksdjlfksdjlf.us-east-2.docdb.amazonaws.com, DNS:sldkfjl.cluster-sldkfjlsdk.us-east-2.docdb.amazonaws.com, DNS:sldkfjl.cluster-ro-sldkfjlsdk.us-east-2.docdb.amazonaws.com
This is what I’m stuck on. I am also using the package connect-mongo
to have a session manager for the login component of my backend, but it would not allow me to have the tslAllowInvalidHostnames
option enabled. Connecting to the DocDB was not a problem–if I didn’t use the package and attempted to upload something, it was fine. Is there a way to test DocDB with the package enabled in any other way? The port forwarding system works as planned.
Essentially, the testing system looks like this:
localhost-frontend --- localhost-backend --- EC2 --- DocDB