RepoScalewayScalewaypublished Jun 19, 2019seen 5d

scaleway/serverless-scaleway-functions

JavaScript

Open original ↗

Captured source

source ↗

scaleway/serverless-scaleway-functions

Description: Plugin for Serverless Framework to allow users to deploy their serverless applications on Scaleway Functions

Language: JavaScript

License: MIT

Stars: 91

Forks: 25

Open issues: 41

Created: 2019-06-19T15:08:52Z

Pushed: 2026-04-14T15:52:10Z

Default branch: master

Fork: no

Archived: no

README:

Scaleway plugin for Serverless Framework

Plugin for using Scaleway Serverless Functions and Serverless Containers with Serverless Framework.

Requirements

If you are using Scaleway IAM, you need to be the Owner of the Scaleway Organization in which the deployment will take place, or be an IAM user of the Organization with a policy granting you the necessary Permission Sets. See the IAM Overview for more information.

Quick start

1. Export the template you wish to use (see the list here). We will use python3:

export TEMPLATE=python3

2. Create a function from this template:

serverless create \
--path ${TEMPLATE}-func \
--template-url https://github.com/scaleway/serverless-scaleway-functions/tree/master/examples/${TEMPLATE}

3. Install dependencies:

cd ${TEMPLATE}-func
npm i

4. Deploy the function:

serverless deploy

5. Invoke the function (note that first is the function name in this example):

serverless invoke --function first

Contents

  • [Quick start](#quick-start)
  • [Configuration](#configuration)
  • [Supported commands](#supported-commands)
  • [Unsupported commands](#unsupported-commands)
  • [Useful links](#useful-links)
  • [Contributing](#contributing)
  • [License](#license)

More detailed documentation can be found in the [docs](docs/) folder, including:

  • [Managing containers](docs/containers.md)
  • [Configuring custom domains](docs/custom-domains.md)
  • [Handling events (e.g. CRONs)](docs/events.md)
  • [Security and secret management](docs/secrets.md)
  • [Troubleshooting](docs/troubleshooting.md)

There are also language-specific notes for Serverless Functions:

  • [Golang functions](docs/golang.md)
  • [Javascript functions](docs/javascript.md)
  • [PHP functions](docs/php.md)
  • [Python functions](docs/python.md)
  • [Rust functions](docs/rust.md)

Configuration

With Serverless Framework, your functions and containers are defined in a serverless.yml file.

Each serverless.yml file corresponds to one function _or_ container namespace.

General configuration

The following configuration is common to both functions and containers:

# The name of your namespace
service: my-namespace

# Read environment variables from a .env file
useDotenv: false

# Use of this plugin. This must not be changed
plugins:
- serverless-scaleway-functions

# Scaleway-specific configuration
provider:
# Must not change
name: scaleway

# Runtime used for functions (unless overridden)
# List: https://www.scaleway.com/en/docs/serverless/functions/reference-content/functions-lifecycle/#available-runtimes
runtime: python310

# Global environment variables, used in every function/container in this namespace
env:
MY_VAR: "some var"
MY_OTHER_VAR: "some other var"

# Global secrets, used in every function/container in this namespace
secret:
MY_SECRET: "some secret"
MY_OTHER_SECRET: "some other secret"

# Optional override of Scaleway credentials
scwToken:
scwProject:

# Scaleway region for the deploy
scwRegion: fr-par

# Include/exclude directories
package:
patterns:
- "!node_modules/**"
- "!.gitignore"
- "!.git/**"

Function-specific configuration

To define functions, you can include a functions block:

functions:
my-func:
# Handler entrypoint
handler: handler.py

# Minimum and maximum number of instances
minScale: 0
maxScale: 10

# Memory limit (in MiB)
# Limits: https://www.scaleway.com/en/docs/serverless/functions/reference-content/functions-limitations/
memoryLimit: 1024

# Maximum duration a request will wait to be served before it times out (in seconds)
# Value in string format ex: "300s" (default: 300 seconds)
timeout: 300s

# Runtime for this function, allows overriding provider.runtime
runtime: node20

# How to handle HTTP. Options: enabled (allow HTTP), or redirected (redirect HTTP -> HTTPS)
httpOption: enabled

# Execution environment to use when running the function. Options: v1 (legacy), v2 (recommended, with improved cold starts)
sandbox: v2

# Controls privacy of the function. Options: public (no authentication), private (token-based authentication)
privacy: public

# Local environment variables, used only in this function
env:
LOCAL_VAR: "local var"

# Local secrets, used only in this function
secret:
LOCAL_SECRET: "local secret"

# Custom domains configured for the function
# https://www.scaleway.com/en/docs/compute/functions/how-to/add-a-custom-domain-name-to-a-function/
custom_domains:
- my-func.some.domain.com

# List of events to trigger the function
events:
- schedule:
rate: "1 * * * *"
# Data passed as input in the request
input:
key-a: "value-a"
key-b: "value-b"

# ID of the private network to attach the function to
privateNetworkId: "3fd741d4-f686-4afc-bcea-d720c695748f"

Container-specific configuration

To define containers, you can include a custom.containers block (note that you can only have functions _or_ custom.containers).

custom:
containers:
my-container:
# Subdirectory holding the Dockerfile, cannot be used with registryImage
directory: container/

# Build arguments to pass when building the container image
buildArgs:
MY_BUILD_ARG: "my-value"

# Name of the registry image, cannot be used with directory
registryImage: nginx:latest

# Minimum and maximum number of instances
minScale: 0
maxScale: 10

# Configuration used to decide when to scale the container up or down
scalingOption:
# Can be one of: concurrentRequests, cpuUsage, memoryUsage
type: concurrentRequests
# Value to trigger scaling up
# It's expressed in:
# - concurrentRequests: number of requests
# -…

Excerpt shown — open the source for the full document.