If you are using OpenWhisk as a provider, all functions inside the service are OpenWhisk Actions.
All of the OpenWhisk Actions in your serverless service can be found in serverless.yml
under the functions
property.
# serverless.yml
service: myService
provider:
name: openwhisk
runtime: nodejs:6 # optional, default is nodejs:default
memorySize: 512 # optional, default is 256
timeout: 30 # optional, default is 60
functions:
hello:
handler: handler.hello # required, handler set in Apache OpenWhisk
name: some_custom_name # optional, default is ${service}_${function}
runtime: nodejs # optional overwrite, default is provider runtime
memory: 512 # optional overwrite, default is 256
timeout: 10 # optional overwrite, default is 60
The handler
property points to the file and module containing the code you want to run in your function.
// handler.js
exports.handler = function(params) {}
You can add as many functions as you want within this property.
# serverless.yml
service: myService
provider:
name: openwhisk
functions:
functionOne:
handler: handler.functionOne
description: optional description for your Action
functionTwo:
handler: handler.functionTwo
functionThree:
handler: handler.functionThree
Your functions can either inherit their settings from the provider
property.
# serverless.yml
service: myService
provider:
name: openwhisk
runtime: nodejs:6
memory: 512 # will be inherited by all functions
functions:
functionOne:
handler: handler.functionOne
Or you can specify properties at the function level.
# serverless.yml
service: myService
provider:
name: openwhisk
runtime: nodejs:6
functions:
functionOne:
handler: handler.functionOne
memory: 512 # function specific
The OpenWhisk provider plugin supports the following runtimes.
- Node.js
- Python
- Php
- Swift
- Binary
- Docker
Please see the following repository for sample projects using those runtimes.