Reference serverless framework generated lambda in cloudformation template

Hello,

What is the easiest way to reference a serverless framework generated lambda function in CF template?

Sorry if this question has already been answered, but I haven’t been able to find an answer to this question in the docs or on this forum.

Thanks!

Do you want to reference a Serverless generated function in a DIFFERENT CloudFormation template? In that case you can reference resources by referencing the stack they are in: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html

If you want to reference in the same CloudFormation template, you can use the logicalIds.

1 Like

I wanted to reference the function in the same stack.

What I actually had to do is use the logical id.
Logical id for serverless autogenerated lambda is:
the lambda function name with the “LambdaFunction” postfix, everything in PascalCase

example:

functions:
  random-name:
    handler: lambda/random-name.default

The logical id is RandomNameLambdaFunction

1 Like