Finding an Instance's Endpoint - Amazon DocumentDB

Finding an Instance's Endpoint

You can find the endpoint for an instance using the Amazon DocumentDB console or the AWS CLI.

Using the Console

To find an instance's endpoint 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 instances.

  3. From the list of instances, choose the name of the instance that you are interested in.

  4. Scroll down to the Details section then locate the instance endpoint.

    
                     Console screenshot showing the details page with the instance endpoint highlighted.
  5. To connect to this instance, scroll up to the Connect section. Locate the connection string for the mongo shell and a connection string that can be used in your application code to connect to your instance.

    
                     Console screenshot showing the connect section with mongo shell and application connection strings highlighted.

Using the AWS CLI

To find the instance endpoint using the AWS CLI, run the following command with these arguments.

Arguments

  • --db-instance-identifier—Optional. Specifies the instance to return the endpoint for. If omitted, returns the endpoint for up to 100 of your instances.

  • --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 on an instance is returned. The Endpoint field has three members, so listing it in the query as in the following example returns all three members. If you're only interested in some of the Endpoint members, replace Endpoint in the query with the members you're interested in, as in the second example.

  • --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.

For Linux, macOS, or Unix:

aws docdb describe-db-instances \ --region us-east-1 \ --db-instance-identifier sample-cluster-instance \ --query 'DBInstances[*].[DBInstanceIdentifier,Endpoint]'

For Windows:

aws docdb describe-db-instances ^ --region us-east-1 ^ --db-instance-identifier sample-cluster-instance ^ --query 'DBInstances[*].[DBInstanceIdentifier,Endpoint]'

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

[ [ "sample-cluster-instance", { "Port": 27017, "Address": "sample-cluster-instance.corcjozrlsfc.us-east-1.docdb.amazonaws.com", "HostedZoneId": "Z2R2ITUGPM61AM" } ] ]

Reducing the output to eliminate the endpoint's HostedZoneId, you can modify your query by specifying Endpoint.Port and Endpoint.Address.

For Linux, macOS, or Unix:

aws docdb describe-db-instances \ --region us-east-1 \ --db-instance-identifier sample-cluster-instance \ --query 'DBInstances[*].[DBInstanceIdentifier,Endpoint.Port,Endpoint.Address]'

For Windows:

aws docdb describe-db-instances ^ --region us-east-1 ^ --db-instance-identifier sample-cluster-instance ^ --query 'DBInstances[*].[DBInstanceIdentifier,Endpoint.Port,Endpoint.Address]'

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

[ [ "sample-cluster-instance", 27017, "sample-cluster-instance.corcjozrlsfc.us-east-1.docdb.amazonaws.com" ] ]

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