I am trying to create a subscriber to SNS topic with a simple filter policy, after some debugging, I find that the simplest possible setting on the subscriber still not working though I did everything following the official document here. I finally do a very simple experiment and here is what I did:
I create an SNS topic and set up 2 SQS subscriber to subscribe it, one doesn’t have filter, the other one have a simple filter policy of
{"SensorName":["test"]}
I then published the following message directly via SNS console by setting “SensorName” attribute to ‘test’, here is the received message content:
{
"Type" : "Notification",
"MessageId" : "6d39fd3d-8792-55d9-b45d-a39230423be9",
"TopicArn" : "arn:aws:sns:us-east-1:162092913718:test_filter",
"Subject" : "11",
"Message" : "1111111aa",
"Timestamp" : "2024-05-04T04:12:00.004Z",
"SignatureVersion" : "1",
"Signature" : "PQ5EPMc+zVcTLecOzwnCCrss7dWDX+9yuccLhvfsnX56gaThpeuxyQfWkTDXuzfcIk5BQHqOmHq+3Fjrn1wJB17FI3gozVlYVd4PM0dgHoivmfcY6724/zufhtZDvbw1b8PE6x5rXEg3D3R6dCdUWdf0Fky5twR1Zwnegw3KMsPPSPWrqyLjj7BDvZOUaLpoq6oeUDmFPkOIt2hV9Kn1Tdgyn3i3ifJvpt09bEnrwFen61+vDuiuEGeCi7uqKG4ggML2QX12dtyEzU7onfJrYj+7Ha6FAS87TcZPm9Qwn1gqcgbuts2IILHyfQEkajX4ZUGAnAGUfWAUOO882GW9jw==",
"SigningCertURL" : "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-60eadc530605d63b8e62a523676ef735.pem",
"UnsubscribeURL" : "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:162092913718:test_filter:4739bfc7-ce1f-4426-be50-6e1573fe9e2c",
"MessageAttributes" : {
"SensorName" : {"Type":"String","Value":"test"}
}
}
The SQS without filter receive it (and above is what’s received), the one with the filter doesn’t, which shouldn’t be the case, and I can’t find what’s going wrong in such a simple example? There must something critical I’ve been missing. Can anyone help?