Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access AWS CloudFormation ARN from inside Lambda Function

I have two Lambda Functions Lambda1 and Lambda2. Lambda1 does some work and sends multiple results to Lambda2 via an SNS Topic called Topic1. Lambda2 then processes the results of Lambda1.

Lambda1 -> Topic1 -> Lambda2

This all works well until I try to build a CloudFormation Template that represents it. I can subscribe Lambda2 to Topic1, but how can I tell Lambda1 which SNS topic to push messages to? After all the topic ARN is not created until the CloudFormation Stack is created.

like image 549
Col Wilson Avatar asked Nov 09 '22 22:11

Col Wilson


1 Answers

You can use single CloudFormation stack to create this scenario. Outputs of your stack can be used to configure Lambda 1 created within the stack to access Topic 1, you just need to give your Lambda cloudformation:DescribeStacks permission and then access your stack outputs from your Lambda code.

like image 164
adamkonrad Avatar answered Nov 15 '22 13:11

adamkonrad