Installing the serverless.com framework for Serverless Functions and Containers
- compute
- serverless
- Serverless-Functions
- Serverless-Containers
- You have an account and are logged into the Scaleway console
- You have generated an API key
- You have installed Node.js on your local computer
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
node
andnpm
installed on your local machine:$ node -v
$ npm -vBoth 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
:npm install -g serverless
Check if the installation was sucessful:
serverless -v
The command above returns the version of the serverless framework installed on your computer.
Create a new Python 3 project, called
myProject
:serverless create --template-url https://github.com/scaleway/serverless-scaleway-functions/tree/master/examples/python3 --path myProject
Enter the newly created project:
cd myProject
Your project contains the following files:
handler.py
- Your function code, written in Python3package.json
- The list of packages for your functionserverless.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
serverless.yml
:scwToken
- Your secret API keyscwProject
- Your project IDscwRegion
- The region in which to deploy your function
Change
handler.py
to contain your function code, then deploy it using:serverless deploy
For more information about the serverless framework, refer to the official documentation.