Sending text messages using SNS

Amazon SNS also provides users with a really easy-to-use interface which allows you to send text messages or SMS messages to one or multiple phone numbers. It also provides you with the ability to classify and send messages based on their criticality, as well as specify the maximum amount that you wish to spend on sending SMS messages each month. So, without wasting any time, let's get straight to it:

  1. To send SMS messages using SNS, first log in to the SNS dashboard by selecting https://console.aws.amazon.com/sns/.
  2. Once logged in, select the Text messaging (SMS) option from the navigation pane. This will bring up the Text messaging (SMS) dashboard, where you can set your SMS preferences as well as send messages to one or more phone numbers. First up, let's set some preferences by selecting the Manage text messaging preferences option from the dashboard.
  1. Fill in the following preference fields:
    • Default message type: SNS provides two message types: Promotional and Transactional. The Promotional option can be selected if the messages that you wish to send require less criticality, for example, simple marketing messages, and so on. On the other hand, Transactional messages are ideally suited for critical messages, such as one-time passwords, transaction details, and so on. SNS optimizes the message delivery for Transactional messages to achieve the best reliability.
At the time of writing this book, sending SMS messages is supported in the countries listed at https://docs.aws.amazon.com/sns/latest/dg/sms_supported-countries.html.

For this particular scenario, I've selected the Promotional option, as shown in the following screenshot:

    • Account spend limit: The maximum amount you wish to spend, in USD, for sending messages in a month. By default, the limit is set to USD 1.00. For this scenario, we are not going to change this value.
Both Promotional and Transactional message types have different costs based on the specified country or region. You can look up the prices at https://aws.amazon.com/sns/sms-pricing/.
    • IAM role for CloudWatch Logs access: This option is used to create an IAM role that basically allows Amazon SNS to write its logs to CloudWatch. Since this is the first time we are configuring this feature, select the Create IAM role option. This will redirect you to a new page where you should select the Allow option to grant SNS the necessary rights. Here is a snippet of the rights that are provided for your IAM role:
{ 
  "Version": "2012-10-17", 
  "Statement": [ 
    { 
      "Effect": "Allow", 
      "Action": [ 
        "logs:CreateLogGroup", 
        "logs:CreateLogStream", 
        "logs:PutLogEvents", 
        "logs:PutMetricFilter", 
        "logs:PutRetentionPolicy" 
      ], 
      "Resource": [ 
        "*" 
      ] 
    } 
  ] 
} 
    • Default percentage of success to sample: This option is used to specify the percentage of successful SMS messages delivered, based on which SNS will write logs into CloudWatch. To write only logs for failed message deliveries, set this value to 0. By default, SNS will write logs for all successful deliveries (100%).
    • Default sender ID: This option is used to specify the name of the message's sender. You can provide any meaningful name here.
    • Reports storage: Use this option to configure an S3 bucket that will store daily SMS usage reports from Amazon SNS. If you are providing an existing bucket as your Reports storage then ensure that it has the necessary access rights to interact with the SNS service.
  1. Once the required fields are filled in, select the Update preferences option to complete the process.

To send the SMS messages, simply select the Send a text message (SMS) option from the Text messaging (SMS) dashboard. This will bring up the Send text message (SMS) dialog box, as shown in the following screenshot. Provide a valid phone Number and a Message. Remember to prefix your country code in the phone number as well:

You can optionally even overwrite the Sender ID field here, however, for this case, we have left it to the default value that was configured in the preferences stage. After the required fields are filled in, simply select Send text message to complete the message-sending process. You can also verify the delivery status of each message sent, either Transactional or Promotional, by using the Account stats section provided in the Text messaging (SMS) page.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset