This template demonstrates how to deploy a NodeJS function running on AWS Lambda using the traditional Serverless Framework. The deployed function does not include any event definitions as well as any kind of persistence (database). For more advanced configurations check out the examples repo which includes integrations with SQS, DynamoDB or examples of functions that are triggered in cron
-like manner. For details about configuration of specific events
, please refer to our documentation.
In order to install the dependencies, you need to run the following command:
npm install
In order to build the service you need to run the following command:
npm run build
In order to test the service locally you need to run the following command:
npx serverless invoke local --function generateDocument --data '{"name":"John Wick"}'
In order to deploy the example, you need to run the following command:
$ serverless deploy
After running deploy, you should see output similar to:
Deploying aws-node-project to stage dev (us-east-1)
โ Service deployed to stack aws-node-project-dev (112s)
functions:
hello: aws-node-project-dev-hello (1.5 kB)
After successful deployment, you can invoke the deployed function by using the following command:
serverless invoke --function generateDocument --data '{"name":"John Wick"}'
Which should result in response similar to the following:
{
"statusCode": 200,
"body": "...",
"headers": {
"Content-Type": "application/json"
}
}
You can invoke your function locally by using the following command:
npx serverless invoke local --function generateDocument --data '{"name":"John Wick"}'
Which should result in response similar to the following:
{
"statusCode": 200,
"body": "...",
"headers": {
"Content-Type": "application/json"
}
}