I have a filter for a SNS subscription (SQS) where I'm using this filtering:
{"source":[{"anything-but":"SOME_STRING"}]}
This works OK, except that sometimes I have messages going to the SNS that doesn't have any message-attribute called source, and before using the filter, this subscription without filter was taking it.
So, in conclusion, I would like to find a way where my filter takes the message if it doesn't have this "source" attribute or in case it have it, it should be anything-but SOME_STRING.
Thank you!
Your requirement is to filter and pass messages if:
Amazon SNS Subscription policy accepts messages under the following conditions.
1) Each attribute name in a filter policy matches an attribute name assigned to the message.
2) For each matching attribute name, at least one match exists between the following:
--> the values of the attribute name in the filter policy
--> the message attributes
As you can see in the given documentation for SNS Subscription filter policies, any message that does not contain the filtering attribute, or if that attribute value does not meet the policy, the message will be rejected.
According to your example, you CANNOT filter and pass messages which does not contain the "source" attribute. But you can filter if the source attribute exists and it should be anything-but SOME_STRING.
Workaround for this.
Assuming that you have access to the message generating source, make sure that every message contains the attribute "source", before pushing it to SNS. Then you can easily filter out if it is anything-but SOME_STRING.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With