0
votes

I'm using 'aws-sdk' gem.

https://github.com/aws/aws-sdk-ruby

Using below gem

'aws-sdk (1.11.0)'

I want to use filtering messages function.

https://docs.aws.amazon.com/sns/latest/dg/message-filtering.html

I understood I should set Filter policy.

but, I could not find how to set it.

I have read below.

https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/sns-examples.html https://docs.aws.amazon.com/sdk-for-ruby/v3/api/index.html

How can I use this function?

Thank you.

1
@rantingsonrails thank you for your advice. thank you for your advice. I checked 'set_topic_attributes' and 'set_subscription_attributes'. but, There is no description about 'FilterPolicy'. According to the CLI example, setting of FilterPolicy seems to be done for subscription. ``` aws sns set-subscription-attributes \ --subscription-arn arn:aws:sns:ap-northeast-1:123456789012:Insurance-Quote-Requests:20ae8621-e33b-4a6e-952c-62fa92bac171 \ --attribute-name FilterPolicy \ --attribute-value '{"insurance_type":["car", "boat"]}' ``` - xaxaxaxaxa

1 Answers

0
votes

I could set FilterPolicy using set_subscription_attributes.
DeliveryPolicy and RawMessageDelivery were valid attribute names in the description of this page, and FilterPolicy could be used too.

https://docs.aws.amazon.com/sdkforruby/api/Aws/SNS/Client.html#set_subscription_attributes-instance_method

params = {subscription_arn: subscription_arn, attribute_name: 'FilterPolicy', attribute_value: '{"event_type": ["order_placed", "order_cancelled"]}'}
client.set_subscription_attributes(params)