Skip to content
Advertisement

Python SSH tunnel into EC2 and connect to DocumentDB

I have been attempting to SSH tunnel into an EC2 instance and connect to DocumentDB that is located in the same VPC. I’ve tried all of the solutions I could dig up online with no luck. I am using the ssh_pymongo module, which wraps SSHTunnelForwarder. I am able to SSH directly into the EC2 instance and connect to the DocumentDB cluster. I’m trying to achieve this same thing via python.

Example code:

JavaScript

Error:

JavaScript

Advertisement

Answer

I also tried the ssh_pymongo module but was unsuccessful. However I tried directly with the sshtunnel module and I was able to query my database.

Here is my code

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement