@aws-sdk/client-sqs send(SendMessageCommand) returning TypeError

116 Views Asked by At

I am trying to send a message to SQS fifo queue by callling sendMessageToSQS function in lambda layer and got TypeError: instruction is not iterable. Below is my function code and error details It worked in my one environment but not other even though we used same git branch no changes in code pipeline. We tried same dataset in both environments but keep failing on in one with same error message.

Any inputs can be of great help.

function code as follows :

const { SQSClient, SendMessageCommand} = require('@aws-sdk/client-sqs');
const REGION = process.env.AWS_REGION;
const client = new SQSClient({ region: REGION });
async function sendMessageToSQS(messageBody, queueName, groupID, key){
    try {
      const command = new SendMessageCommand({
        MessageBody: JSON.stringify(messageBody),
        QueueUrl: queueName,
        MessageGroupId: groupID,
        MessageDeduplicationId: key,
      });
    return await client.send(command);
  }
   catch (err) {
     log.error(err);
     throw new Error(err);
   }
}

module.exports = { sendMessageToSQS };

Error message: { "logLevel": "error", "msg": "instruction is not iterable", "stack": "TypeError: instruction is not iterable"
}

0

There are 0 best solutions below