-
Notifications
You must be signed in to change notification settings - Fork 0
/
snsSmsTest.js
32 lines (27 loc) · 882 Bytes
/
snsSmsTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
let AWS = require('aws-sdk');
const sns = new AWS.SNS();
exports.handler = async function (event, context, callback) {
let receiver = event['receiver'];
let sender = event['sender'];
let message = event['message'];
console.log("Sending message", message, "to receiver", receiver);
try {
let data = await sns.publish({
Message: message,
PhoneNumber: receiver,
MessageAttributes: {
'AWS.SNS.SMS.SMSType': {
DataType: "String",
StringValue: "Promotional"
},
'AWS.SNS.SMS.SenderID': {
DataType: "String",
StringValue: sender
}
}
}).promise();
} catch (err) {
// error handling goes here
};
callback(null, 'Successfully executed');
}