1

I am setting up our AWS infrastructure using CDK in Python. I want to subscribe an sqs queue to an SNS topic using a filter when the id is in a range and the type is one of two types. The filter should look like this:

{ "id": [{"numeric": [">", 0, "<", 100]}], "type": ["foo", "bar"] }

This is what I have:

class MyStack(core.Stack): def init(self, scope: core.Construct, id: str, **kwargs) -> None: super().init(scope, id, **kwargs)

    queue = sqs.Queue(self, "MyQueue")
    snsTopic = sns.Topic(self, "MyTopic", display_name="My Topic")

    idMapping = {"id":  sns.SubscriptionFilter(conditions=[{"numeric": [">", 0, "<", 100] } ])}
    typeMapping = {"type" : sns.SubscriptionFilter(conditions=["foo", "bar"])}

    sub = subs.SqsSubscription(queue, filter_policy = idMapping)
    snsTopic.add_subscription(sub)

It seems to work if I set the filter_policy to either idMapping or typeMapping, but how do I do the AND of the two?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Jay Askren
  • 10,282
  • 14
  • 53
  • 75

1 Answers1

2

just give one dict containing both keys

mapping = {"id": ...,"type" :...)}

Joran Beasley
  • 110,522
  • 12
  • 160
  • 179