Per the title, I want to know how to use CDK to define a payload filter policy for a message body in CDK?
I've tried to get this to work correctly in TypeScript, but am struggling to get it to compile correctly.
Examples for this are lacking but here is an example on how to define a OR policy that looks at the event
field in the message body and only accepts messages where the value is either ASSIGNED
or CANCELLED
:
myTopic.addSubscription(
new SqsSubscription(myQueue, {
filterPolicyWithMessageBody: {
event: sns.FilterOrPolicy.filter(
sns.SubscriptionFilter.stringFilter({
allowlist: [
'ASSIGNED',
'CANCELLED',
],
})
),
},
})
)