I have a pretty basic code snippet to test publishing of messages to SNS from Node Lambda:
exports.handler = async () => {
const AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-2'});
let result;
try {
result = await new AWS.SNS({apiVersion: '2010-03-31'}).publish({
TopicArn: 'arn:aws:sns:us-east-2:99999999999:MyTopic',
Message: 'Body of Message 1',
Subject: 'Message 1'
});
} catch (err) {
console.error('xxxxxxxx', err, err.stack);
throw err;
}
console.info('>>>>>> ' + result.MessageId);
}
However, all I repeatedly get in the logs is >>>>>> undefined
, and of course, the messages are not being published (because the queue subscribed to this is always empty). I can confirm that the Lambda function has the relevant permissions. What am I doing wrong?