Connecting Lambda to Neptune DB CDK

39 views Asked by At

I'm trying to connect a nodeJS lambda to a Neptune serverless instance. I can't get this to work. I've tried just about everything I can think of but the connection always times out. I'm wondering if I'm just completely missing how to connect these two resources. If I can't use a Neptune serverless instance I'm fine using an instance but even that I've not been able to get a connection with.

Any support with this would be greatly appreciated. I've included my CDK stake with a fake Neptune url.

Thank you in advance for any support you can offer.


import {
    aws_lambda as lambda,
    aws_iam  as iam,
} from "aws-cdk-lib";
        const neptuneUrl = "example-db.cluster-cr41xkpkzbr6.eu-west-2.neptune.amazonaws.com";

        const graphDBRole = new iam.Role(this, `${app}-graph-role`, {
            assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
            managedPolicies: [
                iam.ManagedPolicy.fromAwsManagedPolicyName('NeptuneFullAccess'),
                iam.ManagedPolicy.fromAwsManagedPolicyName('CloudWatchLogsFullAccess'),
            ]
        });
    enter code here

const feedbackLambda = new lambdaNodejs.NodejsFunction(
            this,
            `${app}-feedback`,
            {
                runtime: lambda.Runtime.NODEJS_18_X,
                entry: path.join(__dirname, `../lambdas/feedback/index.ts`),
                handler: "index.handler",
                timeout: cdk.Duration.seconds(60),
                role: graphDBRole,
                environment: {
                    REGION: cdk.Stack.of(this).region,
                    ENVIRONMENT: props.environment,
                    MAIN_GRAPH_DB: neptuneUrl,
                },
            }
        );
0

There are 0 answers