0

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?

2

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

I have also prepared a free course that takes you from "What is Serverless?" to building a multi-service Serverless application: serverless.com/learn/courses/…
This is perfect, @GarethMcCumskey

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.