Search code examples
amazon-web-servicesaws-lambdaamazon-sns

How to filter Lambda responses using attributes in SNS from destination?


Now that AWS Lambda supports sending responses directly to SNS without using the AWS API using the 'Destinations' feature, is it possible to include message attributes in the response? In particular in order to do message filtering (e.g. via a subscription filter policy). Something like this:

{ "Message" : "Hello World", "Accepted" : "true" }

We want SNS to look at the Accepted field and forward the message to the next step if true. It looks like this should be possible but I can't find any docs on exactly how to specific the message attributes on a response payload when using a lambda destination rather than the AWS API.

How do we format the lambda response payload so that an SNS attribute filter can operate on it, for a Lambda Destination -> SNS message?


Solution

  • In looking at the Lambda console and the Lambda documentation, I can't see a way to configure Lambda Destinations to include Message Attributes for Amazon SNS.

    Instead, you could code the function itself to send a message to Amazon SNS, specifying the desired message attributes.