Send SMS text messages from AWS in 2022

February 26th, 2022

Texting from AWS

In this quick tutorial, we’ll learn how to send SMS text messages from an AWS account in (or after) 2022. Previously, AWS users did not need to configure a Pinpoint number to send SMS messages from AWS, they could just use SNS and it would work. This is no longer the case, which is why I created this tutorial.

We will create a Toll-Free Number (TFN), which costs $2/month. Then, we will use CloudShell to send an SMS text message and confirm that the number is working. Unfortunately, number registration is a manual process. AWS has no APIs for creating a TFN. If this ever changes, let me know in the comments.

Assumptions

This tutorial assumes that you have the correct permissions to perform all of the commands below, that you do so in the N. Virginia region, and that you are purchasing a US number. Results may vary otherwise!

Instructions

  1. Go to: https://console.aws.amazon.com/pinpoint/home?region=us-east-1#/sms-account-settings/phoneNumbers

  2. Click on Request phone number

  3. Select your country (United States for me)

CAUTION: The following steps might not work for non-US numbers

CloudShell

  1. Select the following:
  • "Toll-free" ("Long code" is cheaper, but requires you to submit your company's EIN number in the US)
  • "SMS"
  • "Transactional"
  1. Click Next
  2. On the following page click Request to finish purchasing your Toll-Free Number

Testing out your new phone number to verify that it works

Now we will use CloudShell to quickly verify if the new phone number is working.

  1. Log into CloudShell. If this is your first time using CloudShell, it may take 5-10m to initialize. You can log by either:

CloudShell

  1. Once, CloudShell finishes initializing and presents you with a prompt, enter the following command, replacing YOUR_PHONE_NUMBER_WITH_COUNTRY_CODE with your personal phone number (including the country code). For example, a US resident might enter: "+15550005555". Enclose the phone number in quotes.
bash
1aws sns publish --phone-number "[YOUR_PHONE_NUMBER_WITH_COUNTRY_CODE]" --message "Test"

If everything is working, your CloudShell terminal should return an output like this:

{
    "MessageId": "fe0d109f-a099-5350-91a4-4a5699bf0815"
}
[cloudshell-user@ip-0-0-0-0 ~]$ ▯

You should also receive a text message at the number you entered!

Cleanup

CAUTION: Remember to delete your Pinpoint phone number when you are finished. You will continue incurring the $2 per month charge as long as it is active.