Reputation: 57
I want to create a class that has multiple functions in aws lambda function. When I want to call a function in class from API gateway. I want to know how to declare that function and in aws lambda function.
Upvotes: 6
Views: 14388
Reputation: 93
You can have multiple functions in a single class. It's just that you have to set the required function as a handler for a particular API gateway on AWS which you are using it for the lambda function that you created. Then when we run our lambda it will only call the set handler function leaving the rest of the functions untouched.
You can even use rest of the function to work with other lambdas or even as a normal function which is called by the handler function internally.
You need to go through the aws lambda documentation for more information.
Upvotes: 1
Reputation: 112
When using AWS-Lambda, there is a difference between the way you implement your code, and the APIs your lambda exposes to the rest of the world.
In your case, it doesn't matter if the functions are of the same class or in different modules, the thing that matters is that you have to link each function call to the correct api-gateway. i would recommend reading about serverless infrastructure , a very useful tool for managing serverless applications, specifically this page of the docs describing function configuration.
Hope this helps!
Upvotes: 1