Joey Yi Zhao
Joey Yi Zhao

Reputation: 42536

How can I put lambda function in a nested stack in serverless?

I am using serverless to manage my AWS resources and come cross this plugin to support nested stacks: https://www.serverless.com/plugins/serverless-plugin-nested-stacks.

I have tried that but it seems that I can only put Resources in a nested stacks. I can't put serverless lambda functions in the nested stack because lambda function uses a different syntax than cloudformation.

For example, below is my lambda function defined in serverless.yml:

logoffHandler:
  handler: src/lambdas.lorcedLogoff
  name: lorcedLogoff

I can't put this definition in a nested stack, I will have to convert it to cloudformation syntax AWS::Lambda::Function. Do I understand it correctly? If I have to use cloudformation syntax to define everything, there is no point to use serverless at all.

Upvotes: 0

Views: 2082

Answers (2)

karjan
karjan

Reputation: 1016

Try using slit stacks plugin https://www.npmjs.com/package/serverless-plugin-split-stacks Worked great for us

Upvotes: 1

Traycho Ivanov
Traycho Ivanov

Reputation: 3207

Here is the serverless guide which define what is possible.

https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/

You could define resources using cloudformation in Resources section. I would say some pieces are only possible by adding them only with cloudformation.

I see your plugin use templates, so I believe you have to follow and create the cloudformation. Plugin is just an integration piece between serverless framework and cloudfromation.

Upvotes: 1

Related Questions