- Newest
- Most votes
- Most comments
Hi,
You can achieve what you want via CloudWatch.
This page explains how SNS SMS delivery can be logged in CW with messages: https://docs.aws.amazon.com/sns/latest/dg/sms_stats_cloudwatch.html
You get then such a message for each SMS:
{
"notification": {
"messageId": "34d9b400-c6dd-5444-820d-fbeb0f1f54cf",
"timestamp": "2016-06-28 00:40:34.558"
},
"delivery": {
"phoneCarrier": "My Phone Carrier",
"mnc": 270,
"numberOfMessageParts": 1,
"destination": "+1nnn5550100",
"priceInUSD": 0.00645,
"smsType": "Transactional",
"mcc": 310,
"providerResponse": "Message has been accepted by phone carrier",
"dwellTimeMs": 599,
"dwellTimeMsUntilDeviceAck": 1344
},
"status": "SUCCESS"
}
You scan either schedule your Lambda via cron every few minutes and scan the CW log stream to report such messages in your RDS instance or be completely even-driven via CloudWatch Event rules (see https://medium.com/@oshara.16/trigger-aws-services-using-cloudwatch-part-1-trigger-a-lambda-function-9fd763ee7755) and have your Lambda triggered on each such message.
Best,
Didier
To set up a webhook that will be invoked on SMS deliveries by Amazon SNS and update your AWS RDS database, you'll need to follow these steps:
-
Create an Amazon SNS topic: This topic will receive notifications about SMS delivery status.
-
Subscribe your Lambda function to the SNS topic: Your Lambda function, which acts as the webhook, should be subscribed to the SNS topic you created. This way, it will be invoked whenever a message is published to the topic.
-
Configure SNS to send delivery status notifications: You need to enable delivery status logging for your SNS topic. This is done by setting specific topic attributes.
Here's how to configure SNS to push messages to the topic after delivering the SMS:
-
Enable delivery status logging for your SNS topic by setting the following attributes:
SMSSuccessFeedbackRoleArn: Set this to the ARN of an IAM role that allows SNS to write successful delivery logs to CloudWatch Logs.SMSFailureFeedbackRoleArn: Set this to the ARN of an IAM role that allows SNS to write failed delivery logs to CloudWatch Logs.SMSSuccessFeedbackSampleRate: Set this to a value between 0-100 to specify the percentage of successful SMS deliveries to log.
-
When you send an SMS through SNS, include the
MessageAttributesparameter withAWS.SNS.SMS.SMSTypeset to "Transactional" andAWS.SNS.SMS.MessageAttributes.DeliveryStatusset to "true". -
SNS will then publish delivery status messages to the specified topic, which will trigger your Lambda function.
-
In your Lambda function, you can process the delivery status information and update your RDS database accordingly.
Remember to ensure that your Lambda function has the necessary permissions to write to your RDS database and that it's configured to run in the same VPC as your RDS instance if required.
This setup will allow you to receive SMS delivery status notifications via your webhook (Lambda function) and update your RDS database based on the delivery status.
Sources
Configuring delivery status logging using the AWS SDKs - Amazon Simple Notification Service
Using AWS Lambda with Amazon RDS - AWS Lambda
Invoking Lambda functions with Amazon SNS notifications - AWS Lambda
Relevant content
- asked 4 years ago
- asked 8 months ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated a year ago

Setting up with CW is costly. Is there any cheaper way to do it?