I have implemented a Subscription Filter Policy in my test account in SNS to only send data coming in a particular subfolder in S3 to my SQS queue. This is working exactly as expected
{
"Records": {
"s3": {
"object": {
"key": [
{
"prefix": "test/test1"
}
]
}
},
"eventName": [
{
"prefix": "ObjectCreated:"
}
]
}
}
However, I am trying to implement the same Subscription policy using CDK but it is giving me below error.
CDK Code:
topic.addSubscription(new subs.SqsSubscription(queue, {
filterPolicyWithMessageBody: {
"Records": {
"s3": {
"object": {
"key": [
{
"prefix": "test/test1"
}
]
}
},
"eventName": [
{
"prefix": "ObjectCreated:"
}
]
}
}
}))
Error:
Type '{ s3: { object: { key: { prefix: string; }[]; }; }; eventName: { prefix: string; }[]; }' is not assignable to type 'FilterOrPolicy'.
Object literal may only specify known properties, and 's3' does not exist in type 'FilterOrPolicy'.