Serverless Deployment of Multiple Features

I recently updated my server project, and I found that a lot has changed in recent updates.

https://serverless.com/

I don’t quite understand what is the correct way to have multiple lambda functions and api gateway endpoints associated with the same project. With the old serverless, I have every lambda and endpoint as a completely separate function, this worked very well for me.

I can no longer do this anymore if I try, the second lambda function redefines my first, apparently because my "service name" is the same for both. My service name is the same because I want both other endpoints in the same API in the Gateway API. Because serverless creates an API name based on the service name.

So, I tried to add both functions to the same "Service". this worked for the most part, except now that I need to include my custom role operator for all my functions in the same role (since this one role is now associated with all my functions). Effectively gives more permissions for each individual function than it should be. Another problem is that all handler files for different functions are placed in each function deployment set.

So, in principle, I’m not sure that the right approach is to have several functions that belong to the same project, but are separate in functionality. It made sense, now not.

If anyone can give me some pointers please

thanks

+7
aws-lambda serverless-framework
source share
2 answers

I understand your disappointment. I had the same feeling until I looked deeper into the new version and began to understand better. It is one thing to note, however, the new version is not yet completely finished. Therefore, if something is completely missing, you can indicate the problem and set the priority until 1.0.

You must define several functions under one service in the functions: serverless.yml . To package these functions separately (exclude code for other functions), you need to set individually: true in the package: section. Then you can use the include and exclude options at the root level and at the function level. The following change will appear, which allows you to use the glob syntax in the include and exclude parameters (example ** / * - fn.js). Here you can find more about packaging https://serverless.com/framework/docs/guide/packaging/ .

You don’t know how to use different roles for different functions under the same service. How did you do it with 0.5?

+5
source share

I tried to find a solution for individual iam roles for each function. I could not find a way to do this, but while I was looking at the documentation, I found the line: "Support for individual IAM roles for each function will appear soon." to this page , so at least we know that they’re working on it.

+1
source share

All Articles