Serverless Rust

homepage icon https://github.com/softprops/serverless-rust
Follow @softprops

Tracked

NPM Downloads Last Month
33
Issues
5
Stars
22
Forks
2
Watchers
22
Watch Star Fork Issue Download License NPM Build Status Coverage Status Contributors

Repo README Contents:

serverless rust Build Status npm

A ⚡ Serverless framework ⚡ plugin for Rustlang applications 🦀

📦 Install

Install the plugin with npm

$ npm install serverless-rust@0.1.6

💡 This serverless plugin assumes you are building Rustlang lambdas using the lando or crowbar rustlang crates.

Add the following to your serverless project’s serverless.yml file

service: demo
provider:
  name: aws
  # crowbar and lando integrate with aws lambda's python3.6 runtime
  runtime: python3.6
plugins:
  # this adds informs servleress to use
  # the serverless-rust plugin
  - serverless-rust
# the follow is recommended for small deployment sizes
# (faster uploads)
package:
  individually: true
  exclude:
    - ./**
functions:
  test:
    # liblambda.handler is the default function name when
    # you follow lando/crowbar conventions
    handler: liblambda.handler
    # the following limits the function packaging
    # to just the resulting binary
    package:
      include:
        - liblambda.so
    events:
      - http:
          path: /test
          method: GET

🖍️ customize

You can optionally adjust the default settings of the dockerized build env using a custom section of your serverless.yaml configuration

custom:
  # this section customizes the default
  # serverless-rust plugin settings
  rust:
    # flags passed to cargo
    cargoFlags: '--features lando/python3-sys'
    # custom docker tag
    dockerTag: 'some-custom-tag'

🎨 Per function customization

If your serverless project contains multiple functions, you may sometimes need to customize the options above at the function level. You can do this by defining a rust key with the same options inline in your function specficiation.

functions:
  test:
    rust:
      # function specific flags passed to cargo
      cargoFlags: '--features ...'
    # liblambda.handler is the default function name when
    # you follow lando/crowbar conventions
    handler: liblambda.handler
    # the following limits the function packaging
    # to just the resulting binary
    package:
      include:
        - liblambda.so
    events:
      - http:
          path: /test
          method: GET

🏗️ serverless templates