2

We have created different config rules for different resources in our AWS account. We have enabled the SNS subscription for the alerts. However, I want to add a filter policy to the subscription that it should give the alerts only for one specific configRule.

Can you please help me how to add filter policy for one specific configRule

knowledge20
  • 1,006
  • 3
  • 14
  • 25

2 Answers2

3

Sadly you can't do this from SNS subscription level. This is because filter policies work only on message attributes, not message body.

The way around this, is to subscribe a lambda function to your SNS topic. The lambda would get the messages from the AWS Config, parse them, and distribute to other msg specific topics or other resources. Since its lambda function, you could program it to do pretty much anything what you want, including rising some alarms.

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • I have added a subscription and chosen email and endpoint as emailid . Then I am trying to apply the filter. Do you any specific format to add the filter? The topic is already receiving the messages I just need to subscribe them in a filtered manner. – knowledge20 Mar 11 '21 at 13:32
  • @knowledge20 As I wrote, you can't do this. Filters don't work on message body. – Marcin Mar 11 '21 at 22:17
  • This is no longer the case. As I shared in my answer below, payload-based message filtering is now supported in SNS. – Otavio Ferreira Mar 02 '23 at 23:24
0

As of November 2022, you can switch to payload-based message filtering in SNS. You simply need to set a subscription attribute named FilterPolicyScope to MessageBody, whereas its default is MessageAttributes. More info: https://aws.amazon.com/blogs/compute/introducing-payload-based-message-filtering-for-amazon-sns/

Otavio Ferreira
  • 755
  • 6
  • 11