4

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?

zx485
  • 28,498
  • 28
  • 50
  • 59
Robel Robel Lingstuyl
  • 1,341
  • 1
  • 11
  • 28
  • I removed your unnecessary code quotes. Please inform yourself [how to use _code sections_](https://stackoverflow.com/help/formatting) in your questions and answers. – zx485 Nov 12 '18 at 22:38
  • @zx485 thanks, I tried to update it but at the time I didn't see the edit option... I'll do better :D – Robel Robel Lingstuyl Nov 13 '18 at 23:05
  • I'm glad that you saw some sense in my comment. Understanding this will give you a bright future on SO. – zx485 Nov 13 '18 at 23:09

2 Answers2

3

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
Leon Carlo Valencia
  • 7,979
  • 1
  • 11
  • 12
0

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).

scho
  • 11
  • 1