• Stars
    star
    546
  • Rank 81,396 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⚑ πŸ¦€ a serverless framework plugin for rustlang applications
⚑ πŸ¦€

serverless-rust

A ⚑ Serverless framework ⚑ plugin for Rustlang applications


πŸ“¦ Install

Install the plugin inside your serverless project with npm.

$ npm i -D serverless-rust

πŸ’‘The -D flag adds it to your development dependencies in npm speak

πŸ’‘ This plugin assumes you are building Rustlang lambdas targeting the AWS Lambda "provided" runtime. The AWS Lambda Rust Runtime makes this easy.

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

service: demo
provider:
  name: aws
  runtime: rust
plugins:
  # this registers the plugin
  # with serverless
  - serverless-rust
# creates one artifact for each function
package:
  individually: true
functions:
  test:
    # handler value syntax is `{cargo-package-name}.{bin-name}`
    # or `{cargo-package-name}` for short when you are building a
    # default bin for a given package.
    handler: your-cargo-package-name
    events:
      - http:
          path: /test
          method: GET

πŸ’‘ The Rust Lambda runtime requires a binary named bootstrap. This plugin renames the binary cargo builds to bootstrap for you. You do not need to do this manually in your Cargo.toml configuration file.

The default behavior is to build your lambda inside a docker container. Make sure you have a docker daemon running if you are not opting into the dockerless mode.

πŸ–οΈ 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 of the default
  # serverless-rust plugin settings
  rust:
    # flags passed to cargo
    cargoFlags: '--features enable-awesome'
    # custom docker tag
    dockerTag: 'some-custom-tag'
    #  custom docker image
    dockerImage: 'dockerUser/dockerRepo'

πŸ₯Ό (experimental) local builds

While it's useful to have a build environment that matches your deployment environment, dockerized builds come with some notable tradeoffs.

The external dependency on docker itself often causes friction as an added dependency to your build.

Depending on a docker image limits which versions of rust you can build with. The default docker image tracks stable rust. Some users might wish to try unstable versions of rust before they stabilize. Local builds enable that.

If you wish to build lambda's locally, use the dockerless configuration setting.

custom:
  # this section allows for customization of the default
  # serverless-rust plugin settings
  rust:
    # flags passed to cargo
    cargoFlags: '--features enable-awesome'
    # experimental! when set to true, artifacts are built locally outside of docker
+   dockerless: true

    # when using local builds (dockerless), optionally provide a different target and linker for the compiler
    # for example, allow local running on ARM macs
    target: aarch64-apple-darwin
    linker: clang

The following assumes that you have not specified a different target or linker. If you do, make sure have that you have installed the specified target (via rustup) and linker.

This will build and link your lambda as a static binary outside a container that can be deployed in to the lambda execution environment using MUSL. The aim is that in future releases, this might become the default behavior.

In order to use this mode its expected that you install the x86_64-unknown-linux-musl target on all platforms locally with

$ rustup target add x86_64-unknown-linux-musl

On linux platforms, you will need to install musl-tools

$ sudo apt-get update && sudo apt-get install -y musl-tools

On Mac OSX, you will need to install a MUSL cross compilation toolchain

$ brew install filosottile/musl-cross/musl-cross

Using MUSL comes with some other notable tradeoffs. One of which is complications that arise when depending on dynamically linked dependencies.

  • With OpenSSL bindings which you can safely replace is with rustls or vendor it
  • Other limitations are noted here.

If you find other MUSL specific issues, please report them by opening an issue.

🎨 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 specification.

functions:
  test:
    rust:
      # function specific flags passed to cargo
      cargoFlags: '--features enable-awesome'
    # handler value syntax is `{cargo-package-name}.{bin-name}`
    # or `{cargo-package-name}` for short when you are building a
    # default bin for a given package.
    handler: your-cargo-package-name
    events:
      - http:
          path: /test
          method: GET

🀸 usage

Every serverless workflow command should work out of the box.

invoke your lambdas locally

$ npx serverless invoke local -f hello -d '{"hello":"world"}'

deploy your lambdas to the cloud

$ npx serverless deploy

invoke your lambdas in the cloud directly

$ npx serverless invoke -f hello -d '{"hello":"world"}'

view your lambdas logs

$ npx serverless logs -f hello

πŸ—οΈ serverless templates

^0.2.*

0.1.*

Older versions targeted the python 3.6 AWS Lambda runtime and rust crowbar and lando applications

Doug Tangren (softprops) 2018-2019

More Repositories

1

action-gh-release

πŸ“¦ :octocat: GitHub Action for creating GitHub Releases
TypeScript
4,124
star
2

envy

deserialize env vars into typesafe structs with rust
Rust
758
star
3

shiplift

🐳 πŸ¦€ rust interface for maneuvering docker containers
Rust
593
star
4

turnstyle

🎟️A GitHub Action for serializing workflow runs
TypeScript
294
star
5

hubcaps

a rust interface for github
Rust
279
star
6

atty

are you or are you not a tty?
Rust
254
star
7

dynomite

βš‘πŸ¦€ 🧨 make your rust types fit DynamoDB and visa versa
Rust
220
star
8

hyperlocal

πŸ”Œ ✨rustlang hyper bindings for local unix domain sockets
Rust
201
star
9

recap

deserialize typed structures from regex captures
Rust
168
star
10

cargo-thanks

πŸ’– πŸ¦€ give thanks to your fellow Rustaceans
Rust
163
star
11

lambda-rust

🐳 πŸ¦€ a dockerized lambda build env for rust applications
Shell
162
star
12

np

new sbt project generation made simple(r)
Scala
149
star
13

openapi

openapi schema serialization for rust
Rust
124
star
14

awesome-mdbook

πŸ•ΆοΈπŸ—ƒοΈ a card catalog of mdbooks for your reading curiosity
122
star
15

serverless-aws-rust

βš‘πŸ—οΈ template for new aws lambda serverless rust apps
Rust
95
star
16

serverless-aws-rust-http

βš‘πŸ—οΈ template for new aws lambda serverless rust http apps
Rust
90
star
17

picture-show

slip and slide picture shows for the web
Scala
77
star
18

goji

a rust interface for jira
Rust
72
star
19

lando

πŸ“¦ πŸš€ a smooth-talking smuggler of Rust HTTP functions into AWS lambda
Rust
69
star
20

serverless-aws-rust-multi

βš‘πŸ—οΈ template for new aws lambda serverless rust http apps
Rust
61
star
21

fasttime

⏱️ A Fastly serverless compute@edge runtime for running wasm applications locally
Rust
60
star
22

again

♻️ Retry faillible Rustlang std library futures
Rust
59
star
23

tugboat

a small boat used for maneuvering docker vessels
Scala
58
star
24

afterparty

rust github webhook server
Rust
55
star
25

coffeescripted-sbt

pour some coffee for scala
Scala
55
star
26

ls

[discontinued] a scala card catalog
Scala
54
star
27

sbt-growl-plugin

Growling sbt test results so you don't have to
Scala
54
star
28

less-sbt

type less css in your sbt projects
CSS
45
star
29

envy-store

πŸͺ deserialize AWS Parameter Store values into type safe structs
Rust
40
star
30

hubcat

hip cats and git hubs
Scala
34
star
31

json-env-logger

A structured JSON logger for Rust.
Rust
30
star
32

zoey

taking scala to the zoo
Scala
29
star
33

serverless-aws-rust-websockets

βš‘πŸ—οΈ template for new aws lambda websocket serverless rust apps
Rust
28
star
34

setup-aws-copilot

πŸ‘©β€βœˆοΈ A GitHub Action for setting up and configuring the AWS Copilot command line interface
TypeScript
26
star
35

treeline

rust in trees
Rust
25
star
36

semverfi

always faithful, always loyal semantic versioning
Scala
23
star
37

unplanned

instant http
Scala
21
star
38

base64

the 64th base of rfc4648
Scala
21
star
39

mint

a makefile linter
Rust
20
star
40

screenprints

reprints for your terminal screen
Rust
19
star
41

porteurbars

🚲 a tool for sharing portable git hosted project templates
Rust
19
star
42

git-codeowners

a git extension to work with CODEOWNERS files
Rust
19
star
43

zig-lambda-runtime

an aws lambda runtime for zig
Zig
19
star
44

heroic

zero to hero Heroku deployment for sbt
Scala
18
star
45

assembly-sbt

Deploy fat JARs. Restart processes.
Scala
18
star
46

cappi

the sweetest sbt plugin your microbenchmarks will ever meet
Scala
17
star
47

capgun

fire when ready
Rust
15
star
48

tubesocks

A comfortable and fashionable way to have bi-directional conversations with modern web servers.
Scala
14
star
49

ryu

A `Tornado Whirlwind Kick` scala client for the riak `raw` http interface
Scala
13
star
50

pine

process line output
Rust
13
star
51

waitout

awaits the completion of multiple async tasks
Rust
12
star
52

sigv4

πŸ”βœοΈ aws sigv4 signed requests on the command line
Rust
12
star
53

emoji-clock

πŸ•’ πŸ‡ I'm late I'm late for a very important date
Rust
12
star
54

scuttlebutt

Listen in on all the gossip going on in your kubernetes cluster πŸ™Š
Rust
12
star
55

rust-bin

πŸ—οΈπŸ—‘οΈ a recipe for Rust bins built, tested, and published with GitHub Actions
Shell
11
star
56

termsize

terminal size matters
Rust
11
star
57

unisockets

unix domain sockets that look just like tcp sockets
Scala
11
star
58

serverless-aws-rust-kinesis

βš‘πŸ—οΈ template for new aws lambda serverless kinesis rust apps
Rust
11
star
59

meow

a scala growl client that purs
Scala
11
star
60

northeast-scala-symposium

event site for the northeast scala symposium
Scala
11
star
61

typed-lambda

Ξ» formal type definitions for aws lambda events
Makefile
10
star
62

codeowners

a rust crate for working with CODEOWNERS files
Rust
9
star
63

captcha_with_question

First attempt at a rails plugin. A form captcha with a textual question.
Ruby
9
star
64

diffset

A GitHub Action for producing lists of files that changed between branches
TypeScript
9
star
65

aws-credential-rotary

TypeScript
9
star
66

treeline-scala

Renders nested tree branches in unicode and ascii
Scala
9
star
67

jot

just a thought
Scala
9
star
68

unfiltered-websockets.g8

unfiltered websockets g8 template
Scala
9
star
69

serverless-localhost

TypeScript
9
star
70

serverless-yml-schema

a json schema file for serverless framework's serverless.yml file
8
star
71

tee

tee for rustlang readers
Rust
8
star
72

guavapants

one pair of pants that makes both your guava _and_ scala types look good
Scala
8
star
73

aws-crossing

🚸 Do cross AWS account work more efficiently
Rust
8
star
74

serverless-lando

βš‘πŸ—οΈ template for new serverless lando apps
Makefile
8
star
75

zig-retry

♻️ Retry faillible zig functions
Zig
7
star
76

sinatra-doc

self documentaion for your sinatra app's routes
Ruby
7
star
77

serverless-oncall

βš‘πŸ“Ÿ Easily manage oncall for your serverless services
TypeScript
7
star
78

action-time

7
star
79

serverless-crowbar

βš‘πŸ—οΈtemplate for new serverless crowbar apps
Makefile
7
star
80

unfiltered-gae.g8

unfiltered google app engine g8 template
Scala
7
star
81

gist

it's like git with an s between the i and t
Scala
7
star
82

zig-graphql

a basic GraphQL client for zig
Zig
7
star
83

sox

comfortable, well fitting documentation for your sbt settings
Scala
6
star
84

spakle

▁▇▁▄▃▂▄▄▆▆▅▃▅▁▂ just like nyc's skyline (or something like that)
Scala
6
star
85

muxup

demo meetup api python app
Python
6
star
86

porthole

tiny rust crate for resolving the next available network port
Rust
6
star
87

typeid-java

A Java implementation of TypeID (Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs).
Java
6
star
88

zig-iter

iterators for zig
Zig
6
star
89

zig-duckdb-ext

πŸ₯ a duckdb extension library for zig
Zig
6
star
90

zig-envy

parse env variables into zig structs
Zig
6
star
91

dispatch-foursquare

databinder dispatch interface for foursquare api
Scala
6
star
92

unfiltered-basic-auth.g8

unfiltered basic auth example g8 template
Scala
5
star
93

pj

a pajama party for your json strings and streamers
Scala
5
star
94

opener

everyone loves a good opener
Scala
5
star
95

ls-sbt

shhhh not ready yet
Scala
5
star
96

unfiltered.g8

template for unfiltered app
Scala
5
star
97

github-actions-schemas

5
star
98

ls-server

[discontinued] scala's local librarian
Scala
5
star
99

chrome-plugin.g8

g8 template for google chrome plugins
Scala
5
star
100

track-jacket

A slimly outfitted interface for getting your app up and running with marathon
Scala
4
star