Amazon SNS Email, SMS and Lambda Notifications Guide

Send SNS notifications by email, SMS and Lambda: confirmation, SMS sandbox, End User Messaging, Lambda permissions, filter policies and limits.

Aug 11, 2025 - 11:18
Nov 14, 2026 - 21:46
 0  48
Amazon SNS Email, SMS and Lambda Notifications Guide

To send Amazon SNS notifications by email, SMS and Lambda, publish to one SNS topic and attach three subscriptions: an email endpoint that the recipient confirms, a phone number for SMS (after you leave the SMS sandbox), and a Lambda function that SNS invokes with the message. Subscription filter policies decide which messages reach which channel.

This guide is about delivery to people and to code: how each of the three channels behaves, what limits AWS enforces, and how to wire them together for real alerts. Creating topics and subscribing queues is covered in our companion post on setting up SNS topics and subscriptions, and the pub/sub model itself in What is AWS SNS.

Key takeaways

  • Email subscriptions must be confirmed by the recipient. AWS positions SNS email for internal system alerts, not marketing, and you cannot customise the message body.
  • An email or email-json endpoint that receives more than 10 messages per second is suspended and moved back to pending confirmation.
  • New accounts start in the SNS SMS sandbox: you can only text verified numbers, up to 10 of them, until you request production access.
  • SNS now delivers SMS through AWS End User Messaging SMS, which handles origination identities, country registration and SMS billing.
  • Lambda subscriptions need a resource-based permission that allows sns.amazonaws.com to invoke the function. SNS invokes Lambda asynchronously.
  • Use filter policies so critical alerts go to SMS while everything goes to Lambda and email.

The pattern: one topic, many channels

A common setup for operations alerts looks like this:

  • A CloudWatch alarm or an application publishes to a topic called ops-alerts.
  • The on-call team's mailing list receives every message by email.
  • The on-call engineer's phone receives SMS only when the message has severity = critical.
  • A Lambda function receives every message, enriches it and posts it to a chat channel or a ticketing system.

The publisher does not know or care about the channels. You add or remove subscribers without changing the code that publishes, which is the main reason to use SNS for notifications rather than calling an email or SMS API directly from each application.

How the three channels compare

ChannelProtocol valueConfirmationLimits and notes
Emailemail or email-jsonRecipient must click Confirm subscriptionStandard topics only; 10 messages per second per endpoint before suspension; no body customisation
SMSsmsNone for the subscription, but sandbox rules applySandbox limits to verified numbers; spending limits; country registration rules
LambdalambdaNone within the same accountNeeds a Lambda resource policy allowing SNS; asynchronous invocation

Step 1: Create the topic

aws sns create-topic --name ops-alerts
# Returns: arn:aws:sns:ap-south-1:111122223333:ops-alerts
TOPIC_ARN=arn:aws:sns:ap-south-1:111122223333:ops-alerts

Use a standard topic for this pattern. FIFO topics exist for strict ordering, but email endpoints can only subscribe directly to standard topics.

Step 2: Email notifications

Subscribe an address:

aws sns subscribe \
  --topic-arn "$TOPIC_ARN" \
  --protocol email \
  --notification-endpoint [email protected]

The response is "SubscriptionArn": "pending confirmation". SNS sends a confirmation email, and nothing is delivered until someone clicks the link. Unconfirmed subscriptions are deleted after 48 hours, so confirm promptly.

Things that catch teams out with email:

  • Email vs email-json. email sends the message text; email-json sends the full SNS JSON envelope, useful when a script parses the inbox.
  • Unsubscribe links. Every email has an unsubscribe link. If the address is a mailing list, one member clicking it unsubscribes the whole list. AWS publishes a guide to require authentication for unsubscribe; use it for shared lists.
  • Throughput. More than 10 messages per second to one email endpoint suspends the subscription into pending confirmation. It is deleted after 30 days unless reconfirmed. Alert storms can trigger this, which is another reason to aggregate alerts in Lambda.
  • Bounces. An address that bounces is suppressed for 7 days.
  • Formatting. You cannot customise the body. For branded or HTML emails, subscribe a Lambda function that sends through Amazon SES instead.

Step 3: SMS notifications

SMS takes more setup than the other two channels because carriers and regulators are involved.

Understand the sandbox

New SNS SMS accounts start in the SMS sandbox. While in the sandbox you can send only to verified destination numbers, you can have up to 10 of them, and you can delete a number only 24 hours after its verification. To text anyone else, request to move your account out of the sandbox, which removes these restrictions.

# Add and verify a sandbox number (an OTP is sent to the phone)
aws sns create-sms-sandbox-phone-number --phone-number +919800000000
aws sns verify-sms-sandbox-phone-number --phone-number +919800000000 --one-time-password 123456

Set origination and registration

SNS delivers SMS through AWS End User Messaging SMS. Origination identities (sender IDs, long codes, toll-free numbers and so on), phone pools, country rules and SMS billing are managed there. Some countries require you to register your company or sender ID before messages are delivered. Check the AWS End User Messaging SMS country table for every country you send to before go-live.

Choose the message type and spending limit

Set the default message type to transactional for alerts (it prioritises reliable delivery) or promotional for lower-cost, non-critical messages, and keep a monthly spending limit so a loop in your code cannot run up a bill:

aws sns set-sms-attributes --attributes \
  DefaultSMSType=Transactional,MonthlySpendLimit=10

Subscribe the phone number

aws sns subscribe \
  --topic-arn "$TOPIC_ARN" \
  --protocol sms \
  --notification-endpoint +919800000000

Phone numbers use E.164 format: a plus sign, country code and number with no spaces. Keep SMS text short, since long messages are split into several billed parts. Recipients can opt out where local rules require it, and SNS keeps an opt-out list you can query with aws sns list-phone-numbers-opted-out.

Step 4: Lambda notifications

A Lambda subscriber turns a notification into an action: post to chat, open a ticket, restart a service, or reformat and forward the alert. SNS invokes the function asynchronously with the message in the event.

Allow SNS to invoke the function

aws lambda add-permission \
  --function-name alert-router \
  --statement-id sns-ops-alerts \
  --action lambda:InvokeFunction \
  --principal sns.amazonaws.com \
  --source-arn "$TOPIC_ARN"

aws sns subscribe \
  --topic-arn "$TOPIC_ARN" \
  --protocol lambda \
  --notification-endpoint arn:aws:lambda:ap-south-1:111122223333:function:alert-router

The --source-arn restricts invocation to this topic. When you subscribe through the Lambda console trigger screen, the console adds this permission for you.

Read the message in the handler

import json

def handler(event, context):
    for record in event["Records"]:
        sns = record["Sns"]
        subject = sns.get("Subject")
        message = sns["Message"]          # the string that was published
        attrs = sns.get("MessageAttributes", {})
        severity = attrs.get("severity", {}).get("Value", "info")
        print(json.dumps({"subject": subject, "severity": severity}))
        # route to chat, ticketing, or remediation here
    return {"status": "ok"}

Because the invocation is asynchronous, configure an on-failure destination or dead-letter queue on the function, and make the handler idempotent. A retried message should not open two tickets. The Lambda monitoring and debugging guide explains how to trace those retries in CloudWatch Logs.

Step 5: Route by severity with filter policies

Without filtering, every subscriber gets every message. Publish with a message attribute, then attach a filter policy to the SMS subscription so only critical alerts reach the phone:

aws sns publish \
  --topic-arn "$TOPIC_ARN" \
  --subject "Disk usage high on web-01" \
  --message "Root volume at 91 percent" \
  --message-attributes '{"severity":{"DataType":"String","StringValue":"critical"}}'

aws sns set-subscription-attributes \
  --subscription-arn arn:aws:sns:ap-south-1:111122223333:ops-alerts:example-sms-sub-id \
  --attribute-name FilterPolicy \
  --attribute-value '{"severity":["critical"]}'

Email and Lambda subscriptions without a filter policy still receive everything. You can also filter on the message body by setting the filter policy scope to MessageBody.

Writing notifications people act on

Delivery is only half the job. An alert that arrives but cannot be understood at 3 a.m. is noise. A few habits make SNS notifications more useful:

  • Put the decision in the subject. Name the service, the environment and the condition, for example "prod checkout: 5xx rate above threshold". Email clients show the subject first, and SMS has little room.
  • Say what to do next. Include a link to the runbook or dashboard in the message body. A Lambda formatter can add this automatically based on the alarm name.
  • Separate severity levels. Use message attributes so warnings go to email and chat while only critical alerts page someone by SMS. Paging people for warnings teaches them to ignore pages.
  • Send a recovery message. CloudWatch alarms publish on the return to OK as well, if you configure an OK action. People should not have to check whether a problem cleared.
  • Keep SMS text short and plain. No JSON, no long URLs if you can avoid them, and nothing sensitive.
  • Review alerts monthly. Remove alerts nobody acted on and tune thresholds that fire too often. Fewer, clearer alerts get faster responses.

Connecting CloudWatch alarms

CloudWatch alarms publish directly to SNS topics. Set the topic as the alarm action and the three channels fire when the alarm changes state. Alarm messages are JSON, which reads badly in an inbox and does not fit in an SMS. A good pattern is to send alarms to Lambda, format a short human message, and publish that to a second "human" topic with email and SMS subscribers. Our article on automating CloudWatch responses with Lambda shows the event side of this flow.

Security and reliability checklist

  • Restrict who can publish with the topic access policy. Only the services and roles that raise alerts should have sns:Publish.
  • Enable server-side encryption on the topic with a KMS key if messages contain sensitive data, and grant CloudWatch or other publishers use of the key.
  • Do not put secrets, passwords or personal data in notifications. Email and SMS leave your control once delivered.
  • Turn on delivery status logging for SMS and Lambda so failed deliveries appear in CloudWatch Logs.
  • Attach a dead-letter queue to subscriptions where losing a message matters.
  • Test the whole path regularly. A monthly "test alert" catches expired email confirmations and opted-out phones before a real incident does.

Troubleshooting

SymptomLikely causeFix
No emails arriveSubscription still pending confirmation, or suspended after a burstCheck status with aws sns list-subscriptions-by-topic; reconfirm
SMS works for some numbers onlyAccount still in the SMS sandboxVerify numbers or request production access
SMS not delivered in a countryRegistration or sender ID rules for that countryCheck AWS End User Messaging SMS country requirements
Lambda never runsMissing resource-based permission for SNSRun aws lambda add-permission with the topic ARN
Duplicate ticketsAsynchronous retries and a non-idempotent handlerUse the SNS MessageId as a deduplication key

SNS notifications versus other AWS options

SNS is not the only way to notify people or code on AWS, and choosing the right service avoids fighting its limits.

For internal alerts to engineers, SNS email and SMS are quick to set up and need no extra service. Their limits are deliberate: plain message bodies, throttled email delivery and confirmation steps. For customer-facing email, such as receipts or password resets, use Amazon SES, which supports templates and custom sender domains. A Lambda subscriber on an SNS topic can bridge the two, receiving an event and sending a formatted SES email.

For work queues, where each message must be processed once by one worker, subscribe an SQS queue to the topic instead of invoking Lambda directly. The queue buffers bursts, and workers can retry failed messages without SNS being involved. Our article on SQS with EC2 or Lambda covers that pattern.

For SMS at larger scale, work directly with AWS End User Messaging SMS, which SNS already uses for delivery. It exposes phone pools, configuration sets, an SMS simulator and country rules that SNS does not surface.

Testing the full notification path

Before relying on a topic for production alerts, test each channel end to end. Publish a test message with each severity value and confirm that the email arrives, that only critical messages reach the phone, and that the Lambda function logs the message and creates the expected ticket or chat post.

Then test failure handling. Point the Lambda subscription at a version that throws an error and confirm that the failed event lands in your dead-letter queue or failure destination. Check that delivery status logs appear in CloudWatch Logs for SMS. Unsubscribe a test email address and make sure your runbook explains how to subscribe it again.

Repeat a lighter version of these tests on a schedule. Email confirmations, phone numbers and team membership change over time, and a notification path that worked at launch can quietly break months later.

Keep the topic, subscriptions, filter policies and Lambda permissions in infrastructure as code rather than creating them by hand in the console. Email and SMS subscriptions still need the confirmation or sandbox steps, but everything else becomes reviewable and repeatable. When an alert path breaks, you can compare the deployed configuration with the code instead of reconstructing what someone clicked months ago. It also makes it simple to create the same notification setup for a new service or a new environment, with different addresses and phone numbers supplied as parameters.

Practise it

This topic, CloudWatch alarm, Lambda and email flow is a good first serverless project to build and explain in interviews. Our AWS Solutions Architect Associate course includes SNS, SQS, Lambda and CloudWatch labs, in the Kharadi, Pune classroom or live online across India.

Frequently asked questions

How do I send an email notification with Amazon SNS?

Create a topic, subscribe an email address with protocol email, have the recipient click the confirmation link, then publish to the topic. Every confirmed subscriber receives the message.

Why are my SNS SMS messages only reaching some numbers?

Your account is probably in the SMS sandbox, which allows only verified destination numbers, up to 10. Request to move out of the sandbox to send to any number.

Can I customise the email that SNS sends?

No. SNS does not support customising the email body and is meant for internal alerts. For formatted or branded emails, have a Lambda subscriber send them through Amazon SES.

How does a Lambda function receive SNS messages?

SNS invokes the function asynchronously. The message is in event["Records"][0]["Sns"]["Message"], with subject and message attributes alongside. The function needs a resource policy that allows sns.amazonaws.com to invoke it.

How do I send only critical alerts by SMS?

Publish messages with a severity message attribute and set a filter policy such as {"severity":["critical"]} on the SMS subscription. Other subscriptions keep receiving everything.

What happens if an email endpoint gets too many messages?

Above 10 messages per second, SNS suspends the subscription and puts it back into pending confirmation. It is deleted after 30 days unless reconfirmed.

Who delivers SNS text messages now?

SNS sends SMS through AWS End User Messaging SMS, which handles routing, origination identities, country compliance and SMS billing.

References

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.