I have a simple node js project, with a server.js file and some dependencies in the node_modules folder. how can i upload the dependencies and the server.js file into lambda function in aws?
1 Answer
I'm assuming the server.js file will have a function that will actually be the lambda, which will be called by whatever means you decide in AWS. To do that you can use the serverless framework in your project and create a serverless.yml file.
So let's say you have src folder and the server.js file within. Within that server.js file you have the lamda function. export const myCustomLambda = (event) => { }. Then on the serverless.yml, in the root directory you do this.
functions:
MyCustomLambda :
handler: src/server.myCustomLambda
With more configuration and after installing the serverless CLI you then deploy it by running serverless deploy
There are more to this, which you can find here in the serverless documentation
serverlessyou can refer to this official doc docs.aws.amazon.com/lambda/latest/dg/nodejs-package.html