I have created an SNS topic and there are several other services subscribed to this topic to receive notifications.
Now, my requirement is to add a filter policy so that only the services that meet the requirement receive the message.
There is support for delivery_policy on terraform, but unable to use filter_policy on SNS.tf directly.
Please suggest if there is any alternative or correct me if my approach is wrong.
PS: I have to do this using terraform and not from AWS console
Thanks, Sumukha
the filter needs to be applied to the subscriber and not the topic it self, let's assume the following config:
resource "aws_sns_topic" "test" {
name = "my-topic-with-policy"
}
resource "aws_sns_topic_subscription" "lambda_sns_subscription" {
topic_arn = "${aws_sns_topic.test.arn}"
protocol = "lambda"
endpoint = "///"
filter_policy = "${jsonencode(map("aa",list("aa")))}"
}
see the filter_policy attribute on the "aws_sns_topic_subscription" resource
and then the fillter needs to be a valid json according to SNS Filter Doc: https://docs.aws.amazon.com/sns/latest/dg/sns-subscription-filter-policies.html
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