5

I was wondering if there is a way to retrieve lambda function metadata during the cloudformation stack creation? We are looking to use the lambda function ARN to further build out other parts of the cloudformation template by storing it in an env variable.

Is this even possible? How do others reference arn when they are unknown until stack creation?

ed

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Edward Hang
  • 95
  • 1
  • 1
  • 4
  • To clarify... you wish to create other resources **in the same CloudFormation template** that refer to the Lambda function. Is that correct? – John Rotenstein Oct 11 '18 at 02:25

2 Answers2

7

You can use the intrinsic functions, specifically Fn::GetAtt to get the lambda function's arn.

See: Fn::GetAtt - AWS CloudFormation

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
cementblocks
  • 4,326
  • 18
  • 24
5

As per this cheatsheet, you would use the following:

json

"MyFieldName": "Fn::GetAtt": ["MyLambdaFunc","Arn"]

yaml

MyFieldName: !GetAtt MyLambdaFunc.Arn
ryanjdillon
  • 17,658
  • 9
  • 85
  • 110