Deploy functions to different FaaS providers with this simple function abstraction made as a Serverless Component.
$ npm install -g serverless
$ mkdir my-function && cd my-function
the directory should look something like this:
|- code
|- handler.js
|- package.json # optional
|- serverless.yml
|- .env # your AWS api keys
// handler.js
module.exports.hello = async (event, context, cb) => {
return { hello: 'world' }
}
# .env
AWS_ACCESS_KEY_ID=XXX
AWS_SECRET_ACCESS_KEY=XXX
name: function
myFunction:
component: '@serverless/function'
inputs:
name: my-function
description: My Serverless Function
memory: 128
timeout: 20
code: ./code
handler: handler.hello
runtime: nodejs8.10
env:
TABLE_NAME: my-table
region: us-east-1
$ serverless
Checkout the Serverless Components repo for more information.