aws-sdk services timing out in lambda nodejs

0

I am currently working on a lambda function in which I have to send a message to an SQS queue. The Lambda function sits inside of a VPC to allow connection with a peered network that the Function makes requests to.

Whenever I try to send the message to SQS however code execution seems to timeout consistently. I had the same issue when I was trying to send commands to DynamoDB.

import { SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs";

const sqsClient = new SQSClient({region: 'us-east-1'});
export const handler = async (event, context, callback) => {
  const response = await sqsClient.send(new SendMessageCommand(messageParams));
  console.log(response); // <----- Doesn't reach here
  return callback(null, 'OK'); 
};

IAM Permissions are all correct and the Security Group allows all traffic (When set to a VPC)

So far, to specifically target the timeout problem, I've tried putting the function in a private subnet, public subnet, placing it in no VPC, replacing SDK v3 with aws-sdk v2 via a layer. None of these seem to have any impact on the issue.

I haven't used VPC endpoints yet but I guess that shouldn't be necessary when the function is not connected to a VPC or in a public subnet?

1개 답변
0

Consistent timeouts when trying to call a public API are usually caused by network misconfiguration which prevents the function from being able to reach the internet. In the case of Lambda functions in a VPC, in order to reach the internet they must be configured in a private subnet with a route through a NAT Gateway. See this article for more info on how this should be configured. Alternatively you can add the appropriate VPC endpoints to allow you function to be able to connect with the required APIs privately.

AWS
Kevin_C
답변함 일 년 전

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

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

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

관련 콘텐츠