How To Send A SMS Using Amazon Simple Notification Service (SNS)

Nafis Faysal
Sep 8, 2019 · 4 min read

In this tutorial, we are going to be looking at how we can use AWS SNS to send SMS.

Goals

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.

Prerequisites

To follow this tutorial, you will have to have the following:

What is the Simple Notification Service?

Source: https://aws.amazon.com/sns

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.

Setup:

  1. 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.

Create AWS credentials

11. We need to install AWS Go SDK in our development machine.

Install AWS Go SDK

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.

Send SMS Using AWS Golang SDK

Further reading

Conclusion

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.

Codephilics

We are a digital transformation consultancy and software…

Codephilics

We are a digital transformation consultancy and software development company that provides cutting edge engineering solutions. Our services are designed to take your business to the next level, reducing the gap between you and the heights of success you wish to achieve.

Nafis Faysal

Written by

Software Engineer — Writer — Open Source Enthusiast — Startup Enthusiast. Reach me out in https://www.linkedin.com/in/nafisfaysal for fast response :)

Codephilics

We are a digital transformation consultancy and software development company that provides cutting edge engineering solutions. Our services are designed to take your business to the next level, reducing the gap between you and the heights of success you wish to achieve.