Hi all! I need some help regarding SNS topics subscriptions configurations in Terraform.
I have a topic called orders. The messages contain an attribute event that can have the values “order-created”, “order-updated” and “order-deleted”. The messages that contain the event “order-updated” also have an attribute changes that can have the values “delivery-address”, “contact”, etc.
What I want to do is to process all the messages that contain “order-created” and “order-deleted” events, but only process the “order-updated” messages which the changes attribute is “delivery-address”.
By now, I’m only applying filter policies to the event attribute, as you can see below.
module "orders-topic" {
source = "../components/messagebus/topic/create"
name = "${local.profiles-name}"
namespace = "${local.namespace}"
}
module "my-queue" {
source = "../components/messagebus/queue/create"
name = "${local.service-name}"
namespace = "${local.namespace}"
sns-topic-count = 1
sns-topic-arns = [
"${module.orders-topic.sns-arn}",
]
apply-filter-message = {
"${module.orders-topic.sns-arn}" = "${jsonencode(map("event",list("orders-created","orders-updated","orders-deleted")))}",
}
}
How could I achieve the wanted behavior? One approach I could think of is to create another module for the orders topic using an alias and apply the new filter policy on this duplicated module, but I am not sure if this is possible or even if this is the best approach.
Any insight would be greatly appreciated.