I have a Lambda function that has some data and must send it to a SQS queue. But it seems like the send is not working. There is no error and it seems to gracefully continue execution without any message being sent. Here is my Lambda code:
//JavaScript
import { SendMessageCommand, SQSClient } from "@aws-sdk/client-sqs";
const message = {
label: "test",
};
const client = new SQSClient({});
const SQS_QUEUE_URL = "https://sqs.us-east-1.amazonaws.com/...";
const send = async (message, sqsQueueUrl = SQS_QUEUE_URL) => {
const command = new SendMessageCommand({
QueueUrl: sqsQueueUrl,
DelaySeconds: 5,
MessageAttributes: {
Label: {
DataType: "String",
StringValue: message.label,
},
},
MessageBody:
"Sent test data to SQS queue",
});
console.log("Test");
const response = await client.send(command);
console.log(response);
return response;
};
send(message, SQS_QUEUE_URL);
Viewing the logs on CloudWatch, I can see the “Test” message being printed, but not the response. I have other things after the send(...)
, all that code works, it’s just the send(...)
that isn’t doing anything. My runtime is Node.js 20.x
.
I have already attached a policy to provide full SQS access for my Lambda function. I also included the region when initializing the client, didn’t seem to make a difference.