Search code examples
amazon-web-servicesamazon-sns

AWS SNS endpoint to topic subscription or filtering or multiple subscription


This question is related, but I am unable to comment or upvote: Amazon SNS multiple subscriptions of the same endpoint

Out of the example of the AWS doc (https://docs.aws.amazon.com/sns/latest/dg/message-filtering.html#message-filtering-example-policy-string-logic):

{
    "customer_interests": ["rugby"],
    "price_usd": [{"numeric":[">", 100]}]
}

I now derrive the following question: How would I set up the filter if an endpoint would like to subscribe to "rugby" with a price over 100 and also to "baseball" with a price below 200?

This overall OR logic is somehow missing in the documentation.

Therefore I thought of subscribing the same endpoint to the topic twice with different filter plicies. One with the filter for "rugby" and price over 100, and one subscription for "baseball" with a price below 200. This was kind of asked in the question of SO (link above).


Solution

  • In Nov 2023, SNS message filtering introduced support for the ‘OR’ operator. This new operator should be able to address your use case.

    More information: https://aws.amazon.com/about-aws/whats-new/2023/11/amazon-sns-message-additional-filtering-operators/