Trigger AWS Lambda via SMS: Step-by-Step Guide
In this guide, we’ll show you how to trigger AWS Lambda via SMS using only AWS managed services. This powerful combination leverages AWS Pinpoint, SNS, and Lambda, and offers a cost-effective solution for triggering compute functions via SMS. Whether you’re a sysadmin or a developer, this approach opens up exciting possibilities for automation and system management.
Before we dive in, please note that some of the resources used here may not be covered under the AWS Free Tier. Additionally, you might need to request certain services via AWS support, especially if you encounter service limitations in your region.

What Are the Core Components?
To trigger an AWS Lambda function via SMS, you’ll need to set up a few key components. These are:
- Customer Engagement: This involves sending the SMS to AWS Pinpoint.
- Application Integration: Using SNS to handle SMS messages and trigger Lambda.
- Compute: AWS Lambda processes the incoming messages.
Let’s walk through the process of setting everything up.
1. Customer Engagement with AWS Pinpoint
The first step in this process is to use AWS Pinpoint, a service that enables customer engagement via channels like SMS, email, and voice. In this case, Pinpoint will be used to handle incoming SMS messages and send them to SNS for further processing.
You’ll need to obtain a long or short code for SMS communication. In some regions, like Bahrain, only long codes are available. To request a code, follow the steps outlined in the Pinpoint documentation.
Tip: If you’re on the AWS free plan, the process may take longer, and you’ll need to raise a support ticket for certain features.
2. Setting Up SNS to Handle SMS Messages
Next, we need to set up SNS (Simple Notification Service). SNS will serve as the intermediary between Pinpoint and Lambda, triggering the function whenever an SMS is received.
- In the AWS Console, navigate to SNS and click on Create Topic.
- Name the topic and leave the default settings as is.
- Once created, this topic will be used to trigger your Lambda function.
3. Prepare IAM Role for Lambda
Before we configure Lambda, it’s essential to create an IAM role that will allow the Lambda function to consume messages from SNS.
- Go to IAM and click on Create Role.
- Select Lambda as the use case.
- Attach the SNS Read-Only Access policy to this role.
- Give the role a descriptive name and complete the process.
4. Configuring the Lambda Function
Now, it’s time to configure the Lambda function that will process the incoming SMS. Lambda allows you to run code without provisioning servers, making it the ideal choice for this use case.
- Go to Lambda in the AWS Console, then click Create Function.
- Fill in the necessary details, and don’t forget to select the IAM role we created earlier.
- Under Designer, click Add Trigger and choose SNS. Select the SNS topic you created in step 2.
Your Lambda function is now ready to process SMS messages. When a message is sent to the specified long/short code, it will trigger the Lambda function automatically.
5. Configuring AWS Pinpoint to Trigger AWS Lambda
With all the services set up, we now need to configure Pinpoint to send SMS messages to the SNS topic.
- In the AWS Console, go to Pinpoint and select Manage Projects.
- Create a new project and skip project features for now.
- Navigate to Settings > SMS and Voice and configure your long/short code.
- Under Two-way SMS, enable the feature and link it to the SNS topic you created.
How to Test Your Setup
Once everything is configured, you can test your setup by sending an SMS to your long/short code. To verify that the Lambda function was triggered successfully, check the Lambda logs.
Practical Use Case: Automating EC2 Management
Now, let’s consider a real-world use case for this setup. Imagine you have an EC2 instance running a marketing dashboard that gets turned off after business hours. One day, your marketing team needs it to be turned on urgently. Instead of manually logging in to the AWS console, you can simply send an SMS to trigger a Lambda function that starts the instance. This approach could save you a lot of time and effort!
Conclusion for Triggering AWS Lambda via SMS
Triggering AWS Lambda via SMS is a simple yet powerful way to automate tasks and integrate AWS services. By leveraging AWS Pinpoint, SNS, and Lambda, you can create efficient workflows that respond to incoming SMS messages. This setup can be used in various scenarios, from system management to business operations.
At ZippyOPS, we specialize in providing consulting, implementation, and managed services in areas like DevOps, DevSecOps, Cloud, Automated Operations, Microservices, Infrastructure, and Security. If you’re looking to integrate similar solutions into your business, we can help. Learn more about our services at ZippyOPS Services.
For more in-depth solutions, explore our products and solutions.
Need help with implementation? Contact us at sales@zippyops.com.
For demos and tutorials, visit our YouTube channel.



