Invoking Lambda functions using Amazon SNS notifications
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 Using Amazon SNS Topic Attributes for Message Delivery Status.
To invoke Lambda functions using Amazon SNS notifications, you need the following:
Amazon SNS topic
Configuring Amazon SNS with Lambda Endpoints with the AWS Management Console
Sign in to the AWS Management Console and open the Amazon SNS console at https://console.aws.amazon.com/sns/.
In the left Navigation pane, click Topics, and then click the topic to which you want to subscribe a Lambda endpoint.
Click Actions and then click Subscribe to topic.
In the Protocol drop-down box, select AWS Lambda.
In the Endpoint drop-down box, select the ARN for the Lambda function.
In the Version or Alias drop-down box, select an available version or alias to use. You can also choose $LATEST to specifiy the latest version of the Lambda function. If you do not want to specify a version or alias, you can also choose default, which is functionally the same as $LATEST. For more information, see AWS Lambda Function Versioning and Aliases.
Click 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 on how to create a sample message history store using SNS, Lambda, and Amazon DynamoDB, see the AWS Mobile Development blog Invoking AWS Lambda functions via Amazon SNS.