Setting SMS messaging preferences in Amazon SNS
Use Amazon SNS to specify preferences for SMS messaging. For example, you can specify whether to optimize deliveries for cost or reliability, your monthly spending limit, how deliveries are logged, and whether to subscribe to daily SMS usage reports.
These preferences take effect for every SMS message that you send from your account, but you can override some of them when you send an individual message. For more information, see Publishing SMS messages to a mobile phone using Amazon SNS.
Setting SMS messaging preferences using the AWS Management Console
Sign in to the Amazon SNS console
. -
Choose a region that supports SMS messaging.
-
On the navigation panel, choose Mobile and then Text messaging (SMS).
-
On the Mobile text messaging (SMS) page, in the Text messaging preferences section, choose Edit.
-
On the Edit text messaging preferences page, in the Details section, do the following:
-
For Default message type, choose one of the following:
-
Promotional – Non-critical messages (for example, marketing). Amazon SNS optimizes message delivery to incur the lowest cost.
-
Transactional (default) – Critical messages that support customer transactions, such as one-time passcodes for multi-factor authentication. Amazon SNS optimizes message delivery to achieve the highest reliability.
For pricing information for promotional and transactional messages, see Global SMS Pricing
. -
-
(Optional) For Account spend limit, enter the amount (in USD) that you want to spend on SMS messages each calendar month.
Important-
By default, the spend quota is set to 1.00 USD. If you want to raise the service quota, submit a request
. -
If the amount set in the console exceeds your service quota, Amazon SNS stops publishing SMS messages.
-
Because Amazon SNS is a distributed system, it stops sending SMS messages within minutes of the spend quota being exceeded. During this interval, if you continue to send SMS messages, you might incur costs that exceed your quota.
-
-
-
(Optional) For Default sender ID, enter a custom ID, such as your business brand, which is displayed as the sender of the receiving device.
NoteSupport for sender IDs varies by country.
-
(Optional) Enter the name of the Amazon S3 bucket name for usage reports.
NoteThe Amazon S3 bucket policy must grant write access to Amazon SNS.
-
(Optional) To log the delivery status of your SMS messages to CloudWatch Logs, expand the Message delivery status logging section, and then set a Success sample rate and provide an IAM role that grants Amazon SNS write access to CloudWatch Logs. For more information, see Viewing CloudWatch Logs.
-
Choose Save changes.
Setting preferences (AWS SDKs)
To set your SMS preferences using one of the AWS SDKs, use the action in that SDK
that corresponds to the SetSMSAttributes request in the Amazon SNS API. With
this request, you assign values to the different SMS attributes, such as your monthly
spend quota and your default SMS type (promotional or transactional). For all SMS
attributes, see SetSMSAttributes in the Amazon Simple Notification Service API Reference.
The following code examples show how to use SetSMSAttributes.
Setting SMS messaging preferences for country-specific delivery
You can control your SMS traffic by sending messages only to specific destination countries. This approach ensures that your messages reach only approved countries and helps you avoid unwanted SMS charges. To do this, you create a protect configuration in AWS End User Messaging SMS that defines per-country send rules for SMS.
To apply a protect configuration to the SMS messages that you send through Amazon SNS, you must associate the protect configuration as the account default. The account default applies at the account level and also affects SMS messages sent through Amazon Cognito and AWS End User Messaging SMS. You can have only one account default protect configuration at a time.
-
Open the AWS End User Messaging SMS console
. -
In the navigation pane, under Protect, choose Protect configuration, and then choose Create protect configuration.
-
For Protect configuration name, enter a descriptive name (for example, Allow-Only-AU).
-
On the SMS country rules tab, select the check box for each country that you want to allow, and then choose Allow. For example, to allow SMS messages only to Australia, select Australia and then choose Allow.
NoteBy default, all destination countries are set to Block. Select only the countries that you want to allow.
-
In the Status change confirmation dialog box, review your changes and choose Confirm.
-
In the Protect configuration associations section, for Association type, choose Account default so that the protect configuration applies to all SMS messages sent through Amazon SNS.
-
Choose Create protect configuration.
The following confirmation message appears:
Success Protect configuration protect-abc0123456789 has been created.
When you set country rules in a protect configuration, you can apply one of the following modes to each destination country. You can apply a different mode to individual countries.
- Allow
-
Send messages to the destination country.
- Block
-
Block all messages to the destination country.
- Monitor
-
Send messages, but include the SMS protect blocking recommendation in metrics and events.
- Filter
-
Send messages, but block traffic suspected of being artificially inflated traffic (AIT).
The Monitor and Filter modes incur additional charges for artificially inflated traffic (AIT) risk evaluation.
After you associate the protect configuration as the account default, AWS End User Messaging SMS applies the protect configuration's country rules to the SMS messages that you publish through Amazon SNS. To see which messages are allowed or blocked, open the Amazon SNS console. In the navigation pane, choose Mobile, and then Text messaging (SMS). This opens the Mobile text messaging (SMS) page, where you can do the following:
-
Configure delivery status logging – In the Text messaging preferences section, provide an IAM role that grants Amazon SNS write access to CloudWatch Logs. For detailed steps, see Viewing CloudWatch Logs. Depending on the destination phone number's carrier, it can take up to 72 hours for delivery logs to appear in the Amazon SNS console.
-
View delivery status logs – In the Delivery status logs section, each message shows a Status and a Provider response. For a destination that the protect configuration blocks, the status is FAILURE and the provider response is
Destination country blocked by SMS protect configuration. -
View delivery statistics – In the Delivery statistics section, blocked messages are counted under Failed.
The same delivery events are also written to CloudWatch Logs in the log group sns/region/AccountID/DirectPublishToPhoneNumber/Failure.
For more information, see Using protect configurations, Change country rules, and Country rule modes in the AWS End User Messaging SMS User Guide.