How To Send A SMS Using Amazon Simple Notification Service (SNS)
In this tutorial, we are going to be looking at how we can use AWS SNS to send SMS.
By the end of this tutorial:
- We will have a solid understanding of AWS SNS.
- We will be able to send a SMS to our phone using AWS Go SDK.
To follow this tutorial, you will have to have the following:
- AWS account.
- Go (Golang programming language) install on your development machine.
What is the Simple Notification Service?
Amazon Simple Notification Service (SNS) is a highly available, durable, secure, fully managed pub/sub messaging service that enables you to decouple microservices, distributed systems, and serverless applications. Amazon SNS provides topics for high-throughput, push-based, many-to-many messaging.
Amazon makes it easy to send a SMS. In this tutorial, we will not create any topic, to keep this tutorial simple. We will use AWS Go SDK to send a SMS with SNS. Don’t worry if you are not familiar with Go Programming Language. I will explain every single detail. Hope this will give you a solid idea on AWS SDK for SNS APIs and you can implement on your preferred Programming Language.
- If you don’t have an AWS account, go to this link create your account, you will get 12-month free trial all most of the AWS services. Awesome right. Visit aws.amazon.com/free for full offer terms.
2. To send SMS via AWS SDK you need to create AWS Access key ID and Secret access key. If you don’t have those key don’t worry we will create it step by step. Go to Identity and Access Management (IAM) Console and from the left side menu click on “Users”.
3. Then click on “Add user”.
4. Create a new “User name” and allow “Programmatic access”. Click “Next: Permissions”
5. Select “Attach existing policies directly” and in the search box write sns, allow “AmazonSNSFullAccess” and click “Next:Tags”
6. Although this part this is optional for the simply I just keep it simple. you can skip this point.
7. Reviews the user setting and permissions and click on “Crete user”.
10. Congratulate you successfully crate AWS Access key ID and Secret access key. Download the key file and open the file in your favorite text editor. Keep them secret and safe.
11. We need to install AWS Go SDK in our development machine.
11. Finally, it’s time to create our send SMS service.
First, we need to initialize a couple of constants for the SMS. And then create a session and pass the phone number and message.
Here you can find full codebase on GitHub.
Boom check your inbox. We successfully send SMS using AWS Go SDK.
What is Amazon Simple Notification Service?
Describes the Amazon SNS web service which coordinates and manages the delivery or sending of messages to subscribing…
I hope you enjoyed the tutorial. Let me know if you have any suggestion on my post in the comments. Thank you for going through this lengthy post. I will be glad if you can share your thoughts with me on Twitter.
You can find it on GitHub.