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
Go to: https://console.aws.amazon.com/pinpoint/home?region=us-east-1#/sms-account-settings/phoneNumbers
Click on Request phone number
Select your country (United States for me)
- Select the following:
- "Toll-free" ("Long code" is cheaper, but requires you to submit your company's EIN number in the US)
- "SMS"
- "Transactional"
- Click Next
- 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.
- Log into CloudShell. If this is your first time using CloudShell, it may take 5-10m to initialize. You can log by either:
Following the direct link here: https://us-east-1.console.aws.amazon.com/cloudshell/home?region=us-east-1# OR
Clicking on the CloudShell icon in the upper-right corner of the browser (see image below).
- 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.
bash1aws 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!