# Error in SNS configuration for pre-existing SNS topic?

**URL:** <https://forum.serverless.com/t/error-in-sns-configuration-for-pre-existing-sns-topic/1954>\
**Category:** Serverless Framework\
**Created:** [May 28, 2017, 5:21pm UTC](https://forum.serverless.com/t/error-in-sns-configuration-for-pre-existing-sns-topic/1954 "2017-05-28T17:21:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cdichiara](https://avatars.discourse-cdn.com/v4/letter/c/71e660/32.png) [@cdichiara](https://forum.serverless.com/u/cdichiara)\
**Post date:** [May 28, 2017, 5:21pm UTC](https://forum.serverless.com/t/error-in-sns-configuration-for-pre-existing-sns-topic/1954/1 "2017-05-28T17:21:07Z")

</div>

Hi,

Not sure if this is an error … but the behavior is surprising, so I thought I’d report it.

```auto
  handleSesSuppressions:
    handler: handleSesSuppressions.handler
    events:
      - sns:
          arn: ${{self:resources.Outputs.BouncesSnsTopic.Value}}
          topicName: ${{file(./commonResources/serverless.yml):provider.environment.BouncesSnsTopic}}
      - sns:
          arn: ${{self:resources.Outputs.ComplaintsSnsTopic.Value}}
          topicName: ${{file(./commonResources/serverless.yml):provider.environment.ComplaintsSnsTopic}}

```

This deploys. As seen in `cloudformation-template-update-stack.json`:

```auto
    "HandleSesSuppressionsSnsSubscriptionIrhsesbounces": {
      "Type": "AWS::SNS::Subscription",
      "Properties": {
        "TopicArn": {
          "Fn::Sub": "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:irh-ses-bounces"
        },
        "Protocol": "lambda",
        "Endpoint": {
          "Fn::GetAtt": [
            "HandleSesSuppressionsLambdaFunction",
            "Arn"
          ]
        }
      }
    },

```

However, this does not deploy:

```auto
  handleSesSuppressions:
    handler: handleSesSuppressions.handler
    events:
      - sns: ${{self:resources.Outputs.BouncesSnsTopic.Value}}
      - sns:
          arn: ${{self:resources.Outputs.ComplaintsSnsTopic.Value}}
          topicName: ${{file(./commonResources/serverless.yml):provider.environment.ComplaintsSnsTopic}}

```

Produces this error message:

```auto
     Missing or invalid topicName property for sns event
     in function "handleSesSuppressions" The correct syntax
     is: sns: topic-name-or-arn OR an object with arn and
     topicName OR topicName and displayName. Please check
     the docs for more info.

```

It seems like I am meeting the requirements for using a pre-existing SNS topic by not including the Topic Name:

> **[Serverless Framework - AWS Lambda Events - SNS](https://www.serverless.com/framework/docs/providers/aws/events/sns/)**
>
> Setting up AWS SNS Events with AWS Lambda via the Serverless Framework

  
Which seems redundant, since it’s included in the ARN:

```auto
    BouncesSnsTopic:
      Description: SNS topic to receive SES bounces.
      Value:
        Fn::Sub: arn:aws:sns:${AWS::Region}:${AWS::AccountId}:${{file(./commonResources/serverless.yml):provider.environment.BouncesSnsTopic}}

```

Am I reading the documentation incorrectly?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [May 29, 2017, 12:23am UTC](https://forum.serverless.com/t/error-in-sns-configuration-for-pre-existing-sns-topic/1954/2 "2017-05-29T00:23:24Z")

</div>

The docs say that using:

```auto
- sns: ${{self:resources.Outputs.BouncesSnsTopic.Value}}

```

will only work if `${{self:resources.Outputs.BouncesSnsTopic.Value}}` resolves to a value starting with `arn:`

Read the second half of the docs covering the usage with intrinsic CloudFormation functions. The `topicName` is required and the `topciArn` must contain the value given in `topicName`.

---

<div class="post-metadata">

**Author:** ![cdichiara](https://avatars.discourse-cdn.com/v4/letter/c/71e660/32.png) [@cdichiara](https://forum.serverless.com/u/cdichiara)\
**Post date:** [May 29, 2017, 12:42am UTC](https://forum.serverless.com/t/error-in-sns-configuration-for-pre-existing-sns-topic/1954/3 "2017-05-29T00:42:14Z")

</div>

Ah, gotcha, thanks for explaining. The reason it threw both me and my fellow developers is because similar approaches have worked in other places, I think - in other words, replacing a literal string starting with “arn:” could be replace with a “Fn::Sub: arn:xxx:” etc. string. For example, it works in the “arn:” field but not the “sns:” field. So I think you could imagine our confusion that wasn’t resolved by the documentation of that page.

Thanks!
