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 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:
function1: aws-node-project-dev-hello (1.5 kB)
To avoid re-building the whole cloud formation stack just run theploy in an individual function:
sls deploy function -f my-function
Log all deployed functions locally (faster than Cloud Watch and free)
sls dev --verbose
sls dev -f my-function
After successful deployment, you can invoke the deployed function by using the following command:
serverless invoke --function function1
Which should result in response similar to the following:
{
"statusCode": 200,
"body": "{\n \"message\": \"Go Serverless v3.0! Your function executed successfully!\",\n \"input\": {}\n}"
}
You can invoke your function locally by using the following command:
serverless invoke local --function hello
Which should result in response similar to the following:
{
"statusCode": 200,
"body": "{\n \"message\": \"Go Serverless v3.0! Your function executed successfully!\",\n \"input\": \"\"\n}"
}
serverless invoke local -f functionName --data '{"a":"bar"}'