π Serverless Hello World example that runs every 2 minutes
Rename env.example.json
file to env.json
file when deploying
Make sure you have Node.js installed and run:
$ npm i serverless -g
You can use serverless
& sls
interchangeably
Then, check the version to make sure you are using V1.16.0, or later:
$ sls -v
First, log in to the serverless platform in via the CLI
$ sls login
After logging into the platfrom via the serverless framework CLI every deploy will be published to the Serverless Platform.
Create a new service using the Node.js template, specifying a unique name and an optional path for your service.
$ sls create --template aws-nodejs --path my-service
Change directory to the new service
$ cd my-service
Use this when you have made changes to your Functions, Events or Resources in serverless.yml
or you simply want to deploy all changes within your Service at the same time.
Give it a try with a new service, or an existing service:
$ sls deploy -v
Invokes a Function and returns logs.
$ sls invoke -f hello -l
Open up a separate tab in your console, set your Provider Credentials and stream all logs for a specific Function using this command.
$ sls logs -f hello -t
If at any point, you no longer need your service, you can run the following command to remove the Functions, Events and Resources that were created, and ensure that you don't incur any unexpected charges.
$ sls remove
To learn more about Serverless, checkout Serverless Framework, The Power of Serverless, Awesome Serverless & Serverless Stack