Skip to content

HTTP Endpoint of Neptune Writer not found from Lambda

0

Hello team! Testing the below Lambda yields the following error:

undefined	ERROR	Uncaught Exception 	{"errorType":"Error","errorMessage":"getaddrinfo ENOTFOUND https://db-simplify-mvp-dev-instance-1.cwezylrm9ic8.us-east-1.neptune.amazonaws.com:8182","code":"ENOTFOUND","errno":-3008,"syscall":"getaddrinfo","hostname":"https://db-simplify-mvp-dev-instance-1.cwezylrm9ic8.us-east-1.neptune.amazonaws.com:8182","stack":["Error: getaddrinfo ENOTFOUND https://db-simplify-mvp-dev-instance-1.cwezylrm9ic8.us-east-1.neptune.amazonaws.com:8182","    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)"]}

I also tried with the Writer endpoint: db-simplify-mvp-dev.cluster-cwezylrm9ic8.us-east-1.neptune.amazonaws.com - same error. I also tried with and without the https:// prefix in the host and hostname - same error.

This is the Lambda code:

import { HttpRequest} from "@aws-sdk/protocol-http";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
import { NodeHttpHandler } from "@aws-sdk/node-http-handler";
import { SignatureV4 } from '@aws-sdk/signature-v4';
import { Sha256 } from '@aws-crypto/sha256-js';

var request = new HttpRequest({
        body: JSON.stringify({"query":"MATCH+%28n%29+RETURN+n+LIMIT+1"}),
        headers: {
            'Content-Type': 'application/json',
            'host': `https://db-simplify-mvp-dev-instance-1.cwezylrm9ic8.us-east-1.neptune.amazonaws.com:8182`
        },
        hostname: `https://db-simplify-mvp-dev-instance-1.cwezylrm9ic8.us-east-1.neptune.amazonaws.com:8182`,
        method: 'POST',
        path: '/openCypher'
    });
    
    var signer = new SignatureV4({
        credentials: defaultProvider(),
        region: 'us-east-1',
        service: 'neptune-db',
        sha256: Sha256
    });

    const signedRequest = await signer.sign(request);
    
    // Send the request
    var client = new NodeHttpHandler();
    var { response } =  await client.handle(signedRequest);
    console.log(response.statusCode + ' ' + response.body.statusMessage);
    var responseBody = '';
    await new Promise(() => {
      response.body.on('data', (chunk) => {
        responseBody += chunk;
      });
      response.body.on('end', () => {
        console.log('Response body: ' + responseBody);
      });
    }).catch((error) => {
        console.log('Error: ' + error);
    });

This is a **NodeJS 18 Runtime **Lambda. Lambda execution role has these policies:

AmazonEC2FullAccess
NeptuneFullAccess
AWSLambdaBasicExecutionRole
AmazonSSMReadOnlyAccess
AWSLambdaVPCAccessExecutionRole

VPC Configuration is:

Enter image description here

Neptune Instance is available and configured:

Enter image description here

The Neptune Security Group has inbound rules to allow the Lambda Security Group on port 8182:

Neptune Writer SG Inbound Rules

Please point me to where I'm missing anything. Thank you! Mor

  • Does the Security Group assigned to Neptune allow traffic on port 8182 from the security group that you assigned to your Lambda function?

  • You also may need to remove https:// from the hostname and host parameters of your HttpRequest.

  • Thank you, Taylor! Yes, I tried with and without https:// and I added an image of the Neptune SG inbound rules, hope that is cleared for traffic.

1 Answer
1

As per the comments above: You need to remove https:// from the start of the hostname and :8182 from the end of it - neither of those two things are part of the hostname; they are part of the URI.

Alternately, instead of hostname you might try using url because that allows you to specify the protocol (https) and the port (81812).

EXPERT

answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.