My team is in the process of creating a project which follows the serverless architecture, we are using AWS Lambda, NodeJS, and Serverless framework. The application will be a set of services each one will be handled as a separate function.
I found examples combining multiple functions under the same project then using cloud formation to deploy all at once, but with some defects we don't want, like having resources of different modules deployed for each lambda function, which will cause some redundancy and if we want to change one file it will not be reflected in all lamda functions as it's local to the hosting lamda function
https://github.com/serverless/examples/tree/master/aws-node-rest-api-with-dynamodb
My question:
do you know the best way to organize a project containing multiple functions, each one has it's separate .yaml
and configurations with the ability to deploy all of them when needed or specify selective updated functions to be deployed?
Serverless applications usually consist of multiple Lambda functions. Each Lambda function can use only one runtime but you can use multiple runtimes across multiple functions. This enables you to choose the best runtime for the task of the function.
Each region in your AWS account has a Lambda concurrency limit. The limit applies to all functions in the same region and is set to 1000 by default.
Using multithreading in AWS Lambda can speed up your Lambda execution and reduce cost as Lambda charges in 100 ms unit.
I think I found a good way to do this in a way like the one mentioned here : https://serverless.readme.io/docs/project-structure
I created a service containing some Labmda functions , each one is contained within a separate folder , also I had a lib folder on the root level containing all the common modules that can be used in my Lambda functions .
So my Structure looks like :
Root ---
functions----
function1
function2
libs---
tests--
resources
serverless.yml (root level)
and in my yml file I'm pointing to Lamdas with relative paths like :
functions:
hello1:
handler: functions/function1/hello1.hello
Now I can deploy all functions with one Serverless command , or selectively deploy the changes function specificity
and the deployed Lamda will only contain the required code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With