Amazon Neptune
User Guide (API Version 2017-11-29)

Using the Gremlin Console to Connect to a Neptune DB Instance

The Gremlin Console allows you to experiment with TinkerPop graphs and queries in a REPL (read-eval-print loop) environment.

You can use the Gremlin Console to connect to a remote graph database. The following section walks you through the configuration of the Gremlin Console to connect remotely to a Neptune DB instance. You must follow these instructions from an Amazon EC2 instance in the same virtual private cloud (VPC) as your Neptune DB instance.

To connect to Neptune using the Gremlin Console

  1. The Gremlin Console binaries require Java 8. Type the following to install Java 8 on your EC2 instance.

    sudo yum install java-1.8.0-devel
  2. Type the following to set Java 8 as the default runtime on your EC2 instance.

    sudo /usr/sbin/alternatives --config java

    When prompted, enter the number for Java 8.

  3. Download Gremlin Console (version 3.3.2+) from the Apache Tinkerpop3 website on to your EC2 instance.

  4. Unzip the Gremlin Console zip file.

  5. Change directories into the unzipped folder.

    cd apache-tinkerpop-gremlin-console-3.3.2
  6. In the conf subdirectory of the extracted directory, create a file named neptune-remote.yaml with the following text. Replace your-neptune-endpoint with the hostname or IP address of your Neptune DB instance. The square brackets ([ ]) are required.


    For information about finding the hostname of your Neptune DB instance, see the Finding the Endpoint for a Neptune Cluster section.

    hosts: [your-neptune-endpoint] port: 8182 serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { serializeResultToString: true }}
  7. In a terminal, navigate to the Gremlin Console directory (apache-tinkerpop-gremlin-console-3.3.2), and then type the following command to run the Gremlin Console.


    You should see the following output:

    \,,,/ (o o) -----oOOo-(3)-oOOo----- plugin activated: tinkerpop.server plugin activated: tinkerpop.utilities plugin activated: tinkerpop.tinkergraph gremlin>

    You are now at the gremlin> prompt. You will type the remaining steps at this prompt.

  8. At the gremlin> prompt, type the following to connect to the Neptune DB instance.

    :remote connect tinkerpop.server conf/neptune-remote.yaml
  9. At the gremlin> prompt, type the following to switch to remote mode. This sends all Gremlin queries to the remote connection.

    :remote console
  10. Type the following to send a query to the Gremlin Graph.

  11. When you are finished, type the following to exit the Gremlin Console.



Use a semicolon (;) or a newline character (\n) to separate each statement.

Each traversal preceding the final traversal must end in next() to be executed. Only the data from the final traversal is returned.

For more information on the Neptune implementation of Gremlin, see Neptune Gremlin Implementation Differences.

For more information about Amazon Neptune, see Next Steps.