@serverless/function

Deploy a function to multiple FaaS providers w/ this simple Function abstraction built as a Serverless Component

Usage no npm install needed!

<script type="module">
  import serverlessFunction from 'https://cdn.skypack.dev/@serverless/function';
</script>

README

function

Deploy functions to different FaaS providers with this simple function abstraction made as a Serverless Component.

 

  1. Install
  2. Create
  3. Configure
  4. Deploy

 

1. Install

$ npm install -g serverless

2. Create

$ 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

3. Configure

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

4. Deploy

$ serverless

 

New to Components?

Checkout the Serverless Components repo for more information.