# Obtain ARN of SNS subscription set up automatically by SLS

**URL:** <https://forum.serverless.com/t/obtain-arn-of-sns-subscription-set-up-automatically-by-sls/17775>\
**Category:** Serverless Framework\
**Tags:** aws, lambda, cloudformation\
**Created:** [October 24, 2022, 11:43am UTC](https://forum.serverless.com/t/obtain-arn-of-sns-subscription-set-up-automatically-by-sls/17775 "2022-10-24T11:43:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![henhal](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/henhal/32/2671_2.png) [@henhal](https://forum.serverless.com/u/henhal)\
**Post date:** [October 24, 2022, 11:43am UTC](https://forum.serverless.com/t/obtain-arn-of-sns-subscription-set-up-automatically-by-sls/17775/1 "2022-10-24T11:43:52Z")

</div>

I use SLS to create a lambda function with an SNS topic event trigger:

```auto
MyFunc:
  handler: ...
  events:
    - sns:
        arn: arn:aws:sns:eu-west-1:xxxxxxxxx:some_topic-prod # from a stack variable

```

This renders the following in CF:

```auto
"MyFuncSnsSubscriptionSometopicprod": {
      "Type": "AWS::SNS::Subscription",
      "Properties": {
        "TopicArn": "arn: arn:aws:sns:eu-west-1:xxxxxxxxx:some_topic-prod",
        "Protocol": "lambda",
        "Endpoint": {
          "Fn::GetAtt": [
            "MyFuncLambdaFunction",
            "Arn"
          ]
        }
      }
    }

```

Now, I need to pass the ARN of the _subscription_ (not the _topic_) to my lambda function as an environment variable. How can I get a reference to this resource?

There are some tricks regarding getting the CF name of another lambda function etc which I’m already aware of (function name + “LambdaFunction”), but here it gets very ugly to reference the resource by the name generated by SLS, which seems to be Function name + “SnsSubscription” + name of SNS topic converted to titlecase and with all special characters stripped away. 😕

Is there some clever way to either choose the name of the SNS subscription so that I can use `!Ref ANameThatIChose`, or is there a plugin or something to scan the CF template for a resource matching a criteria (e.g. `type: AWS::SNS::Subscription`)?  
Or do I have to skip generating this event and manually create the CF for it? ☹
