# Unable to import exported SNS topic arn

**URL:** <https://forum.serverless.com/t/unable-to-import-exported-sns-topic-arn/10294>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [January 17, 2020, 9:39pm UTC](https://forum.serverless.com/t/unable-to-import-exported-sns-topic-arn/10294 "2020-01-17T21:39:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaous](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/xiaous/32/3899_2.png) [@xiaous](https://forum.serverless.com/u/xiaous)\
**Post date:** [January 17, 2020, 9:39pm UTC](https://forum.serverless.com/t/unable-to-import-exported-sns-topic-arn/10294/1 "2020-01-17T21:39:10Z")

</div>

I am trying to setup a function in one stack that uses an imported SNS topic for an event. Below is the exported SNS topic.

```auto
resources:
  Resources:
    CustomSNSTopic:
      Type: "AWS::SNS::Topic"
      Properties:
        DisplayName: 'CustomSNSTopic'
        TopicName: ${self:custom.SNSTopicName}
  Outputs:
    ExportSNSArn:
      Description: The ARN for the exported SNS topic
      Value:
        "Ref": CustomSNSTopic
      Export:
        Name: ${opt:stage}-CustomSNSTopic

```

When I deploy this stack I can see the ARN in the CloudFormation dashboard.  
I’m then trying to import this value so I can setup a lambda to have it as an event. When I assign an env variable with `{'Fn::ImportValue': ${opt:stage}-CustomSNSTopic}` I can see the arn in the lambda console. But when I try adding that here it fails.

```auto
  Function:
    handler: lambda.handler
    events:
      - http:
          path: somepath
          method: post
      - sns: {'Fn::ImportValue': {"Fn::Sub" : "${opt:stage}-CustomSNSTopic"}}

```

I haven’t been able to find any documentation to get this working and would love some help please.

---

<div class="post-metadata">

**Author:** ![hanusj](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/hanusj/32/4076_2.png) [@hanusj](https://forum.serverless.com/u/hanusj)\
**Post date:** [February 27, 2020, 12:32am UTC](https://forum.serverless.com/t/unable-to-import-exported-sns-topic-arn/10294/2 "2020-02-27T00:32:51Z")

</div>

I’ve got exactly same issue ☹

---

<div class="post-metadata">

**Author:** ![edlea](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/edlea/32/4024_2.png) [@edlea](https://forum.serverless.com/u/edlea)\
**Post date:** [March 2, 2020, 2:33pm UTC](https://forum.serverless.com/t/unable-to-import-exported-sns-topic-arn/10294/3 "2020-03-02T14:33:00Z")

</div>

I think you need an object with the arn and topicName in your second snippet (you might need, or want, to output the topic name rather than hard code it as I have below)

```
Function:
  handler: lambda.handler
  events:
    - http:
        path: somepath
        method: post
    - sns:
        arn: 
           Fn::ImportValue: ${opt:stage}-CustomSNSTopic
        topicName: ${self:custom.SNSTopicName}
```

---

<div class="post-metadata">

**Author:** ![Eque19](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@Eque19](https://forum.serverless.com/u/Eque19)\
**Post date:** [March 5, 2020, 3:08pm UTC](https://forum.serverless.com/t/unable-to-import-exported-sns-topic-arn/10294/4 "2020-03-05T15:08:25Z")

</div>

since i’m getting the exact same issue as OP i was hoping to get help.  
edlea, thanks for your response, will try and come with an update.  
i still need some help with my [delice recipes](https://delicerecipes.com/) projects. thanks

---

<div class="post-metadata">

**Author:** ![xiaous](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/xiaous/32/3899_2.png) [@xiaous](https://forum.serverless.com/u/xiaous)\
**Post date:** [March 5, 2020, 3:26pm UTC](https://forum.serverless.com/t/unable-to-import-exported-sns-topic-arn/10294/5 "2020-03-05T15:26:13Z")

</div>

@Eque19 I was in fact able to solve it. I had to import the value into a custom var and then use the correct format when referencing the topic as an event as @edlea pointed out.

```auto
Function:
    handler: App::App.Functions::Function
    events:
      - http:
          path: function
          method: post
      - sns: 
          arn: ${self:custom.importedSnsTopic}
          topicName: "${opt:stage}-importedSnsTopic"

custom:
  importedSnsTopic:
    Fn::ImportValue: '${opt:stage, self:provider.stage}-ImportedTopic'

```

Hope that helps!
