skip to Main Content

I would like to know how I can create a filtering policy for AWS SNS subscription that would check a message attribute value but only if that attribute is present. By default if I check an attribute value but attribute is not present message is ignored e.g:

"customer_interests": ["paintball"]

I also found this for attribute presence checking:

"customer_interests": [{"exists": true}]

But I’m not sure how to combine this two checks into a single policy.

I’ve tried the obvious thing:

{
   "customer_interests": [{"exists": false}, "paintball"]
}

but it doesn’t work.

2

Answers


  1. You apply OR logic in SNS subscription filter policies, by assigning multiple values to an attribute name.

    Your example:

    {
       "customer_interests": [{"exists": false}, "paintball"]
    }
    

    should result in filtering messages that:

    • do not have the customer_interests message attribute
    • OR have the customer_interests message attribute set to paintball

    Please note that additions or changes to a subscription filter policy require up to 15 minutes to fully take effect, as Amazon SNS is eventually consistent.

    Changes will not always take effect immediately.

    Login or Signup to reply.
  2. i have tried the following thing ( your obvious thing ) and it worked for me, i didn’t have to even wait for 15 minutes (clearly eventual consistency is not the issue )

    Used the following policy

    {
      "customer_interests": [
        {
          "exists": false
        },
        "paintball"
      ]
    }
    
    • Created a sns topic with email-based subscription
    • added filter policy to subscriber

    tried with three use case

    Case 1

    • message hello
    • attribute type string
    • atrribute name customer_interests
    • atrribute value paintball
    • status recieved

    Case 3

    • message hello
    • attribute type string
    • atrribute name customer_interests
    • atrribute value xyz
    • status not recieved

    Case 3

    • message hello
    • attribute type string
    • atrribute name jatin
    • atrribute value test
    • status recieved
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search