Robel Robel Lingstuyl
Robel Robel Lingstuyl

Reputation: 1591

Serverless SNS filterPolicy does not put filter in place when subscription created

I'm using the following function definition:

missing:
    handler: functions/eeegMissing.handler
    events:
      - sns: arn:aws:sns:us-west-2:xxx
        filterPolicy:
              type:
                - EPILOG_PAGE_DATA_RECEIVED

The SNS topic already exists. When I deploy it, a subscription is created with the name

arn:aws:lambda:us-west-2:xxx:function:eeeg-dev-missing` 

but the filter is blank. I would expect the filter to show as:

{ "type":["EPILOG_PAGE_DATA_RECEIVED"]}

What am I missing?

Upvotes: 4

Views: 2933

Answers (2)

scho
scho

Reputation: 11

To clarify the previous answer, per the Serverless docs, when specifying a topic by arn (versus name), the arn value must include the arn: keyword (in addition to the arn: prefix included in the AWS resource name).

Upvotes: 0

Leon Carlo Valencia
Leon Carlo Valencia

Reputation: 8757

You just have a minor syntax error. I have a Serverless function with the following event and it works:

events:
- sns: 
    arn: ${self:custom.devicesTopicArn}
    filterPolicy:
      operation:
      - INSERT

So in your case, it should be:

missing:
  handler: functions/eeegMissing.handler
  events:
    - sns:
        arn: arn:aws:sns:us-west-2:xxx
        filterPolicy:
          type:
            - EPILOG_PAGE_DATA_RECEIVED

Upvotes: 3

Related Questions