Skip to content

Instantly share code, notes, and snippets.

@valgaze
Created July 25, 2019 02:40
Show Gist options
  • Select an option

  • Save valgaze/96b5205aebaef3565654c90971403b5f to your computer and use it in GitHub Desktop.

Select an option

Save valgaze/96b5205aebaef3565654c90971403b5f to your computer and use it in GitHub Desktop.
Connect to AWS DocumentDB

** Context: ** DocumentDB has no public endpoints and lives in its own VPC, the upshot of which is that to interact with the data (ie get a shell) you must tunnel/hop through an EC2 instance in the same VPC as the DocumentDB cluster

0) Start up a "helper instance" in same VPC as the DocumentDB Cluster

  • SSH to the instance

1) Setup instance to work with mongo

Important: you need rds-combined-ca-bundle.pem on the instance, which is listed in instructions above

Connect to mongobdb (from SSH):

Enter the following command (swap out URL and username & password)

$ mongo --ssl --host your-docdb-2035-01-02-03-04-05.cluster-abcdefghijk123.us-west-2.docdb.amazonaws.com:27017 --sslCAFile rds-combined-ca-bundle.pem --username USER_NAME_HERE --password PASSWORD_HERE

View data commands once authenticated above

$ show dbs #should see a database named "documentdb"

$ use documentdb

$ show collections # should show only one collection named "events"

$ db.events.find() # dump everything on screen

$ exit # Kill your session

Disconnect

$ exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment