AWS Neptune Configuration

Configure Amazon Neptune as the graph provider for Graphiti

Neptune DB is Amazon’s fully managed graph database service that supports both property graph and RDF data models. Graphiti integrates with Neptune to provide scalable, cloud-native graph storage with automatic backups, encryption, and high availability.

Prerequisites

Neptune DB integration requires both Neptune and Amazon OpenSearch Serverless (AOSS) services:

  • Neptune Service: For graph data storage and Cypher query processing
  • OpenSearch Serverless: For text search and hybrid retrieval functionality
  • AWS Credentials: Configured via AWS CLI, environment variables, or IAM roles

For detailed setup instructions, see:

Setup

  1. Create a Neptune Database cluster in the AWS Console or via CloudFormation
  2. Create an OpenSearch Serverless collection for text search
  3. Configure VPC networking and security groups to allow communication between services
  4. Note your Neptune cluster endpoint and OpenSearch collection endpoint

Configuration

Set the following environment variables:

$export NEPTUNE_HOST=your-neptune-cluster.cluster-xyz.us-west-2.neptune.amazonaws.com
>export NEPTUNE_PORT=8182 # Optional, defaults to 8182
>export AOSS_HOST=your-collection.us-west-2.aoss.amazonaws.com

Installation

Install the required dependencies:

$pip install graphiti-core

Connection in Python

1import os
2from graphiti_core import Graphiti
3from graphiti_core.driver.neptune_driver import NeptuneDriver
4
5# Get connection parameters from environment
6neptune_uri = os.getenv('NEPTUNE_HOST')
7neptune_port = int(os.getenv('NEPTUNE_PORT', 8182))
8aoss_host = os.getenv('AOSS_HOST')
9
10# Validate required parameters
11if not neptune_uri or not aoss_host:
12 raise ValueError("NEPTUNE_HOST and AOSS_HOST environment variables must be set")
13
14# Create Neptune driver
15driver = NeptuneDriver(
16 host=neptune_uri, # Required: Neptune cluster endpoint
17 aoss_host=aoss_host, # Required: OpenSearch Serverless collection endpoint
18 port=neptune_port # Optional: Neptune port (defaults to 8182)
19)
20
21# Pass the driver to Graphiti
22graphiti = Graphiti(graph_driver=driver)