Amazon Neptune Gremlin .NET SigV4
For example usage refer to: NeptuneGremlinNETSigV4Example.cs. This example shows how to leverage this library for establishing an authenticated connection to Neptune.
For general information on how to connect to Amazon Neptune using Gremlin and best practices, refer to the documentation.
A snippet of the code from NeptuneGremlinNETSigV4Example.cs:
var neptune_host = "neptune-endpoint"; // ex: mycluster.cluster.us-east-1.neptune.amazonaws.com var neptune_port = 8182; var gremlinServer = new GremlinServer(neptune_host, neptune_port); var gremlinClient = new GremlinClient(gremlinServer, webSocketConfiguration: new SigV4RequestSigner().signRequest(neptune_host, neptune_port)); var remoteConnection = new DriverRemoteConnection(gremlinClient); var g = Traversal().WithRemote(remoteConnection);
GremlinClient library accepts both a
GremlinServer object as well as a
webSocketConfiguration object that contains a custom configuration set for establishing the WebSocket connection to Amazon Neptune. The SigV4RequestSigner library fetchs IAM credentials using the
FallbackCredentialsFactory API (which works similarly to the Java Default Credential Provider Chain), performs the proper Signature Version 4 signing of an http request, and creates the proper WebSocket configuration based on this signed http request. One can then pass this
webSocketConfiguration to the
GremlinClient to create the connection to Neptune.
Using within Amazon EC2
To use this library in an application hosted on EC2, be sure to assign a role to the EC2 instance with the proper permissions to access Amazon Neptune. This library will fetch the IAM role credentials from the EC2 metadata store. If an IAM role is not assigned to the instance, the library will look for the
SESSION_TOKEN environment variables or look for an AWS CLI credentials file at
Using within AWS Lambda
To use this library in an application hosted in a Lambda function, be sure to assign a role to the EC2 instance with the proper permissions to access Amazon Neptune. Upon invocation, the Lambda function will import the IAM role's credentials into the following environment variables:
AWS_SESSION_TOKEN. This library will use those environment variables to import the credentials and perform the request signing.
See CONTRIBUTING for more information.
This project is licensed under the Apache-2.0 License.