const AWS = require('aws-sdk'); exports.handler = async (event, context) => { // Get the SQS client. const sqs = new AWS.SQS({ region: process.env.AWS_REGION, }); // Receive a batch of messages from the queue. const messages = await sqs.receiveMessage({ QueueUrl: process.env.QUEUE_URL, BatchSize: 10, }); // Process the messages. if (messages.Messages) { for (const message of messages.Messages) { // Do something with the message. console.log(message.Body); } // Delete the messages from the queue. await sqs.deleteMessage({ QueueUrl: process.env.QUEUE_URL, ReceiptHandle: messages.Messages[0].ReceiptHandle, }); } };