I've got a lambda function which is fired via API Gateway (this works).
The lambda then adds some data to the DynamoDB (this works)
Then I call a function I've created which sends data to the SQS
export const AddToQueue = async vehicleId => {
const QueueParams = {
DelaySeconds: process.env.QUEUE_DELAY,
MessageAttributes: {},
};
QueueParams.MessageAttributes.vehicleId = {
DataType: 'String',
StringValue: vehicleId,
};
QueueParams.QueueUrl = 'my-queue-url';
QueueParams.MessageBody = `vehicle: ${vehicleId} - ${new Date().toISOString()}`;
try {
await sqs.sendMessage(QueueParams).promise();
console.log(`SQS:SUCCESS - AddToQueue - ${vehicleId}`);
} catch (error) {
console.log(`SQS:ERROR - AddToQueue - ${error}`);
}
};
The first time this happens the message doesn't get to the SQS, but any other subsequent message is added to the queue and is handled. I've tried a whole bunch of things IAM permissions, settings on the queue, recreating the queue and none of this has helped.
I don't receive a success or error message so have no way to debug any issue.