Connecting to Endpoints - Amazon DocumentDB
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Connecting to Endpoints

When you have your endpoint, either cluster or instance, you can connect to it using the mongo shell or a connection string.

Connecting Using the mongo Shell

Use the following structure to construct the string that you need to connect to your cluster or instance using the mongo shell:

mongo \ --ssl \ --host Endpoint:Port \ --sslCAFile rds-combined-ca-cn-bundle.pem \ --username UserName \ --password Password
mongo shell examples

Connect to a cluster:

mongo \ --ssl \ --host sample-cluster.corcjozrlsfc.us-east-1.docdb.amazonaws.com:27017 \ --sslCAFile rds-combined-ca-cn-bundle.pem \ --username UserName \ --password Password

Connect to an instance:

mongo \ --ssl \ --host sample-cluster-instance.corcjozrlsfc.us-east-1.docdb.amazonaws.com:27017 \ --sslCAFile rds-combined-ca-cn-bundle.pem \ --username UserName \ --password Password

Connecting Using a Connection String

Use the following structure to construct the connection string that you need to connect to your cluster or instance.

mongodb://UserName:Password@endpoint:port?replicaSet=rs0&ssl_ca_certs=rds-combined-ca-cn-bundle.pem
Connection string examples

Connect to a cluster:

mongodb://UserName:Password@sample-cluster.cluster-corlsfccjozr.us-east-1.docdb.amazonaws.com:27017?replicaSet=rs0&ssl_ca_certs=rds-combined-ca-cn-bundle.pem

Connect to an instance:

mongodb://UserName:Password@sample-cluster-instance.cluster-corlsfccjozr.us-east-1.docdb.amazonaws.com:27017?replicaSet=rs0&ssl_ca_certs=rds-combined-ca-cn-bundle.pem