Referencing CloudFormation Outputs

This might be a simple question but I can’t figure out how to reference the output from CloudFormation in my serverless.yml file. What I would like to do is actually capture some of the information for the items created as events for my functions and use them as environment variables. For instance, one of my functions is triggered by SNS and looks like this:

sendAlert:
handler: SendAlert/handler.sendAlert
memorySize: 128
events:
- sns:
topicName: ${self:custom.sendAlertTopicName}

What I’d like to be able to do is get the ARN for the topic that gets created and set it to an environment variable calld SEND_ALERT. How do I capture this and set it in the yaml file?

Thanks in advance,
Nick

Hey does your serverless file similar this: serverless-sns-issue/serverless.yml at master · ProbablePrime/serverless-sns-issue · GitHub ?

I’m having what sounds like a similar issue. There’s some discussion here:

I’m looking around for some details and found: Create a subscription between my Amazon SQS queue and an Amazon SNS topic in CloudFormation which seems helpful.

I’ll be trying out some stuff on the above repo today and will let you know if i get anywhere.

Edit: I Fixed it!!!

The key part here is the Ref function available in cloudformation. Ref - AWS CloudFormation