Amazon Simple Notification Service
Developer Guide

Using Amazon SNS for System-to-System Messaging with an AWS Lambda Function as a Subscriber

Amazon SNS and AWS Lambda are integrated so you can invoke Lambda functions with Amazon SNS notifications. When a message is published to an SNS topic that has a Lambda function subscribed to it, the Lambda function is invoked with the payload of the published message. The Lambda function receives the message payload as an input parameter and can manipulate the information in the message, publish the message to other SNS topics, or send the message to other AWS services.

In addition, Amazon SNS also supports message delivery status attributes for message notifications sent to Lambda endpoints. For more information, see Amazon SNS Message Delivery Status.

Prerequisites

To invoke Lambda functions using Amazon SNS notifications, you need the following:

  • Lambda function

  • Amazon SNS topic

For information about creating a Lambda function, see Getting Started with AWS Lambda. For information about creating an Amazon SNS topic, see Create a Topic.

Configuring Amazon SNS with Lambda Endpoints using the AWS Management Console

  1. Sign in to the Amazon SNS console.

  2. On the navigation panel, choose Topics.

  3. On the Topics page, choose a topic.

  4. In the Subscriptions section, choose Create subscription.

  5. On the Create subscription page, in the Details section, do the following:

    1. Verify the chosen Topic ARN.

    2. For Protocol choose AWS Lambda.

    3. For Endpoint enter the ARN of a function.

    4. Choose Create subscription.

When a message is published to an SNS topic that has a Lambda function subscribed to it, the Lambda function is invoked with the payload of the published message. For information about how to create a sample message history store using Amazon SNS, Lambda, and Amazon DynamoDB, see the AWS Mobile Development blog Invoking AWS Lambda functions via Amazon SNS.