Cloudformation SNS subscription filterpolicy with "or" conditions of "and" expressions

0

I use AWS YAML cloudformation to create SNS subscription and need filter policy with multiple "or" conditions each having "and" expressions.

Something like:

{"creditAccountNumber": ["00001"], "status": ["OK", "CANCEL"] } or {"debitAccountNumber": ["00001"], "status": ["OK", "CANCEL"] }

It would be something similar to cloudformation below(wich doesn't work).

  ObjectTest:
    Type: AWS::SNS::Subscription
    Properties:
      RawMessageDelivery: true
      Protocol: sqs
      Endpoint: ...
      Region: ...
      TopicArn: ...
      FilterPolicy: !Or
        - '{"creditAccountNumber": ["00001"], "status": ["OK", "CANCEL"] }'
        - '{"debitAccountNumber": ["00001"], "status": ["OK", "CANCEL"] }'

Does anyone know how to do it correctly?

Thanks.

2개 답변
1

Seems you can't even do that kind of SNS subscription filter policy directly. As per the AWS documentation https://docs.aws.amazon.com/sns/latest/dg/and-or-logic.html:

Currently, you can't use SNS filters to apply OR logic across different message attributes. Instead, you can use multiple SNS subscriptions with different endpoints to achieve the same effect. For example, assume that you have message attributes named customer_interests and customer_preferences. To apply OR logic across both attributes, create an SNS subscription to match each message attribute. Then, you can use your subscriber application to consume both types of messages through the different endpoints.

profile picture
joahna
답변함 2년 전
0

In Nov 2023, SNS message filtering added support for the “OR” operator in filter policies. More information: https://aws.amazon.com/about-aws/whats-new/2023/11/amazon-sns-message-additional-filtering-operators/

Otavio
답변함 5달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠