Installing the serverless.com framework for Serverless Functions and Containers
The serverless framework is a command line tool, written in Node.js. It allows you to create and mange your Serverless Functions and Serverless Containers resources from the command line.
Check that you have
npminstalled on your local machine:
$ node -v
$ npm -v
Both commands should return the installed version of each tool.Note:
The serverless framework works with Node.js 6.x or later.
Install the serverless framework using
npm install -g serverless
Check if the installation was sucessful:
The command above returns the version of the serverless framework installed on your computer.
Create a new Python 3 project, called
serverless create --template-url https://github.com/scaleway/serverless-scaleway-functions/tree/master/examples/python3 --path myProject
Enter the newly created project:
Your project contains the following files:
handler.py- Your function code, written in Python3
package.json- The list of packages for your function
serverless.yml- Your serverless configuration
Install the Serverless Functions plugin in your project:
serverless plugin install -n serverless-scaleway-functions
Update the following fields in the generated
scwToken- Your secret API key
scwProject- Your project ID
scwRegion- The region in which to deploy your function
handler.pyto contain your function code, then deploy it using:
For more information about the serverless framework, refer to the official documentation.