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개 답변
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).

profile pictureAWS
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠