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?