I'm sending sms from AWS through the node SDK. SMS are going out well and I'm trying to get delivery informations. Apparently it's not that easy and one has to setup SNS to send logs to Cloudwatch and to parse CloudWatch to get the delivery information looking up the MessageId: http://stackoverflow.com/a/40327061/2054629
If I send sms through SNS web interface, logs I see logs in cloudwatch, but not when I send them through the node SDK. I could not get information on how to setup things before sending them from node.
Ideally, I want to achieve something like:
const sendSMS = async (message, number) => {
// send the SMS
// wait to get delivery info
// resolve with delivery info, or reject if failed
}
Currently I have:
import AWS from 'aws-sdk';
AWS.config.update({
accessKeyId: accessKey,
secretAccessKey: secretKey,
region: 'us-east-1',
});
const sns = new AWS.SNS();
const sendSMS = async (message, number) => {
return await new Promise((resolve, reject) => {
sns.publish({
Message: 'this is a test message',
MessageStructure: 'string',
PhoneNumber: myPhoneNumber
}, (err, res) => {
if (err) { return reject(err); }
resolve(res);
});
});
}
which only send a SMS request to AWS and resolves with something like
{
ResponseMetadata: { RequestId: '7e0999a3-xxxx-xxxx-xxxx-xxxxxxxxxxxx' },
MessageId: 'f7f21871-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
}
I'm not sure if one has to setup an SNS application to be able to get logs or not, and I'd rather not to keep things simple.
via Guig
No comments:
Post a Comment