# Having an issue with setting up SNS triggers

**URL:** <https://forum.serverless.com/t/having-an-issue-with-setting-up-sns-triggers/9758>\
**Category:** Serverless Framework\
**Tags:** aws, lambda\
**Created:** [November 4, 2019, 6:16pm UTC](https://forum.serverless.com/t/having-an-issue-with-setting-up-sns-triggers/9758 "2019-11-04T18:16:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanchamp-ICE](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/ryanchamp-ice/32/446_2.png) [@ryanchamp-ICE](https://forum.serverless.com/u/ryanchamp-ICE)\
**Post date:** [November 4, 2019, 6:16pm UTC](https://forum.serverless.com/t/having-an-issue-with-setting-up-sns-triggers/9758/1 "2019-11-04T18:16:31Z")

</div>

Hello,

I’m trying to create a couple of lambdas that respond to SNS topics. My code is as follows:

```auto
  iamRoleStatements:
    - Effect: Allow
      Action:
        - sns:Publish
        - sns:Subscribe
      Resource: !Ref PublishTopic

functions:
  Publish:
    handler: com.PublishHandler
    events:
      - sns:
        arn: !Ref PublishTopic
        topicName: ${self:provider.stage}-publish-topic
        filterPolicy:
          state:
            - start
  SNSToSlack:
    handler: com.SlackHandler
    events:
      - sns:
        arn: !Ref PublishTopic
        topicName: ${self:provider.stage}-publish-topic

```

And further down I have the following:

```auto
resources:
  Resources:
    PublishTopic:
      Type: AWS::SNS::Topic
      Properties:
        DisplayName: ${self:provider.stage}-publish-topic
    PublishTopicEmailSubscription:
      Type: AWS::SNS::Subscription
      Properties:
        Endpoint: <email address here>
        Protocol: email
        TopicArn: !Ref PublishTopic

```

For some reason, the triggers/subscriptions for the lambdas are never getting created when I deploy. (The email subscription defined in the resources section works fine) If I go into the console and manually set up the triggers this works fine. It seems like the `events` section is just straight up getting ignored… Am I missing something? And is setting up that email subscription at the bottom messing the other subscriptions up?

---

<div class="post-metadata">

**Author:** ![hoang-innomizetech](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/hoang-innomizetech/32/3744_2.png) [@hoang-innomizetech](https://forum.serverless.com/u/hoang-innomizetech)\
**Post date:** [November 5, 2019, 4:12pm UTC](https://forum.serverless.com/t/having-an-issue-with-setting-up-sns-triggers/9758/2 "2019-11-05T16:12:00Z")

</div>

You need to add spaces to the **events** configuration as below:

```auto
functions:
  Publish:
    handler: com.PublishHandler
    events:
      - sns:
          arn: !Ref PublishTopic
          topicName: ${self:provider.stage}-publish-topic
          filterPolicy:
            state:
              - start
  SNSToSlack:
    handler: com.SlackHandler
    events:
      - sns:
          arn: !Ref PublishTopic
          topicName: ${self:provider.stage}-publish-topic

```

See this instruction [https://serverless.com/framework/docs/providers/aws/events/sns/](https://serverless.com/framework/docs/providers/aws/events/sns/)
