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
You apply OR logic in SNS subscription filter policies, by assigning multiple values to an attribute name.
Your example:
should result in filtering messages that:
customer_interests
message attributecustomer_interests
message attribute set topaintball
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.
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
tried with three use case
Case 1
Case 3
Case 3