Implement basic SNS message filtering (#1521)
* Add support for FilterPolicy to sns subscription set_filter_attributes * Add basic support for sns message filtering This adds support for exact string value matching along with AND/OR logic as described here: https://docs.aws.amazon.com/sns/latest/dg/message-filtering.html It does not provide support for: - Anything-but string matching - Prefix string matching - Numeric Value Matching The above filter policies (if configured) will not match messages.
This commit is contained in:
parent
6dce7dcb18
commit
d3d9557d49
5 changed files with 194 additions and 8 deletions
|
|
@ -223,11 +223,26 @@ def test_set_subscription_attributes():
|
|||
AttributeName='DeliveryPolicy',
|
||||
AttributeValue=delivery_policy
|
||||
)
|
||||
|
||||
filter_policy = json.dumps({
|
||||
"store": ["example_corp"],
|
||||
"event": ["order_cancelled"],
|
||||
"encrypted": [False],
|
||||
"customer_interests": ["basketball", "baseball"]
|
||||
})
|
||||
conn.set_subscription_attributes(
|
||||
SubscriptionArn=subscription_arn,
|
||||
AttributeName='FilterPolicy',
|
||||
AttributeValue=filter_policy
|
||||
)
|
||||
|
||||
attrs = conn.get_subscription_attributes(
|
||||
SubscriptionArn=subscription_arn
|
||||
)
|
||||
|
||||
attrs['Attributes']['RawMessageDelivery'].should.equal('true')
|
||||
attrs['Attributes']['DeliveryPolicy'].should.equal(delivery_policy)
|
||||
attrs['Attributes']['FilterPolicy'].should.equal(filter_policy)
|
||||
|
||||
# not existing subscription
|
||||
with assert_raises(ClientError):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue