Finding a Cluster’s Endpoints

You can find a cluster’s cluster endpoint and reader endpoint using the Amazon DocumentDB console or AWS CLI.

Using the Console

To find a cluster’s endpoints using the console

  1. Sign in to the AWS Management Console, and open the Amazon DocumentDB console at https://console.aws.amazon.com/docdb.

  2. In the navigation pane, choose clusters.

  3. From the list of clusters, choose the name of the cluster you are interested in.

  4. Scroll down to the Details section and locate the cluster endpoint and the reader endpoint.

    ![

    1. Console screenshot showing cluster details with cluster endpoint and reader endpoint highlighted.
    2. ](/projects/DocumentDB-20201111-en/1b06a01aa459d043b8930d1fbd0cea85.png)
  5. To connect to this cluster, scroll up to the Connect section. Locate the connection string for the mongo shell and a connection string that can be used in the application code to connect to your cluster.

    ![

    1. Console screenshot showing the connect section with mongo shell and application connection strings highlighted.
    2. ](/projects/DocumentDB-20201111-en/961638890d936992a82766a445388bd0.png)

Using the AWS CLI

To find the cluster and reader endpoints for your cluster using the AWS CLI, run the describe-db-clusters command with these parameters.

Parameters

  • --db-cluster-identifier—Optional. Specifies the cluster to return endpoints for. If omitted, returns endpoints for up to 100 of your clusters.

  • --query—Optional. Specifies the fields to display. Helpful by reducing the amount of data that you need to view to find the endpoints. If omitted, all information about a cluster is returned.

  • --region—Optional. Use the --region parameter to specify the Region that you want to apply the command to. If omitted, your default Region is used.

The following example returns the DBClusterIdentifier, endpoint (cluster endpoint), and ReaderEndpoint for sample-cluster.

For Linux, macOS, or Unix:

  1. aws docdb describe-db-clusters \
  2. --region us-east-1 \
  3. --db-cluster-identifier sample-cluster \
  4. --query 'DBClusters[*].[DBClusterIdentifier,Port,Endpoint,ReaderEndpoint]'

For Windows:

  1. aws docdb describe-db-clusters ^
  2. --region us-east-1 ^
  3. --db-cluster-identifier sample-cluster ^
  4. --query 'DBClusters[*].[DBClusterIdentifier,Port,Endpoint,ReaderEndpoint]'

Output from this operation looks something like the following (JSON format).

  1. [
  2. [
  3. "sample-cluster",
  4. 27017,
  5. "sample-cluster.cluster-corlsfccjozr.us-east-1.docdb.amazonaws.com",
  6. "sample-cluster.cluster-ro-corlsfccjozr.us-east-1.docdb.amazonaws.com"
  7. ]
  8. ]

Now that you have the cluster endpoint, you can connect to the cluster using either mongo or mongodb. For more information, see Connecting to Endpoints.