Git Product home page Git Product logo

serverless-rust's Introduction

⚑ πŸ¦€

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

serverless-rust's People

Contributors

chdsbd avatar ilmari avatar jasondavies avatar kenkoooo avatar marcellourbani avatar marijnhurkens avatar matej-mnoucek avatar mattrjacobs avatar sebasmagri avatar softprops avatar stefannienhuis avatar stitchyourphoto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

serverless-rust's Issues

macOS Dockerless Error

πŸ› Bug description

❯ rustup target add x86_64-unknown-linux-musl
info: component 'rust-std' for target 'x86_64-unknown-linux-musl' is up to date
❯ brew install filosottile/musl-cross/musl-cross
Warning: filosottile/musl-cross/musl-cross 0.9.9 is already installed and up-to-date
To reinstall 0.9.9, run `brew reinstall musl-cross`
❯ sls invoke local -f getPosts
Serverless: Running "serverless" installed locally (in service node_modules)
Serverless: Building Rust jkv2-demo.get_posts func...
Serverless: Running local cargo build on darwin
   Compiling cfg-if v0.1.10
   Compiling lazy_static v1.4.0
   Compiling pin-project-internal v0.4.22
   Compiling futures-core v0.3.5
   Compiling slab v0.4.2
   Compiling log v0.4.8
   Compiling version_check v0.9.2
   Compiling proc-macro-hack v0.5.16
error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed

error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `cfg-if`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed

error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: build failed
Serverless: Rust build encountered an error: undefined 101.

🌍 Your environment

serverless version:1.82.0

rust-plugin version:0.3.8

Building docker image from within CircleCI fails

πŸ› Bug description

I'm trying to do continuous deployment (of a private project) on CircleCI. When building the dockerized Rust image, it fails with this message (SLS_DEBUG=true):

Serverless: Building native Rust ingest.import func...
Unable to find image 'softprops/lambda-rust:0.2.1-rust-1.34.1' locally
0.2.1-rust-1.34.1: Pulling from softprops/lambda-rust

Digest: sha256:972b2621171e89d54b3812fa411792a5b384e88dc2af8f5c21b3131f3610f2fe
Status: Downloaded newer image for softprops/lambda-rust:0.2.1-rust-1.34.1
error: could not find `Cargo.toml` in `/code` or any parent directory

Serverless: Dockerized Rust build encountered an error: undefined 1.
 
  Error --------------------------------------------------
  
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Stack Trace --------------------------------------------
 
Error
    at functions.forEach.funcName (/home/circleci/code/node_modules/serverless-rust/index.js:121:15)
    at Array.forEach (<anonymous>)
    at RustPlugin.build (/home/circleci/code/node_modules/serverless-rust/index.js:101:22)
    at BbPromise.reduce (/home/circleci/code/node_modules/serverless/lib/classes/PluginManager.js:422:55)
From previous event:
    at PluginManager.invoke (/home/circleci/code/node_modules/serverless/lib/classes/PluginManager.js:422:22)
    at PluginManager.run (/home/circleci/code/node_modules/serverless/lib/classes/PluginManager.js:453:17)
    at variables.populateService.then (/home/circleci/code/node_modules/serverless/lib/Serverless.js:109:33)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    at process.topLevelDomainCallback (domain.js:120:23)
From previous event:
    at Serverless.run (/home/circleci/code/node_modules/serverless/lib/Serverless.js:96:6)
    at serverless.init.then (/home/circleci/code/node_modules/serverless/bin/serverless:43:28)
    at /home/circleci/code/node_modules/graceful-fs/graceful-fs.js:111:16
    at /home/circleci/code/node_modules/graceful-fs/graceful-fs.js:45:10
    at FSReqWrap.args [as oncomplete] (fs.js:140:20)
From previous event:
    at initializeErrorReporter.then (/home/circleci/code/node_modules/serverless/bin/serverless:43:6)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    at process.topLevelDomainCallback (domain.js:120:23)
From previous event:
    at /home/circleci/code/node_modules/serverless/bin/serverless:28:46
    at Object.<anonymous> (/home/circleci/code/node_modules/serverless/bin/serverless:65:4)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    at findNodeScript.then.existing (/usr/local/lib/node_modules/npm/node_modules/libnpx/index.js:268:14)
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     OS:                     linux
     Node Version:           10.15.3
     Serverless Version:     1.42.2
 
Exited with code 1

It seems as if it can't mount the current directory as a volume?

πŸ€” Expected Behavior

It should have been able to build the image as it does locally.

πŸ‘Ÿ Steps to reproduce

It is a private project, but I'm pretty sure it happens with any serverless-rust project on CircleCI.

🌍 Your environment

Running on CircleCI, from image rust:latest-node and a remote docker env set up.

OS: linux
Node Version: 10.15.3
Serverless Version: 1.42.2
plugin version: 0.3.4

Debug info seems to be lost when deployed to Lambda

Hi there,

I've been back and forth with Sentry trying to figure out why debug information seems to be completely lost when in the deployed Lambda environment--very strangely, the same project compiled directly in the underlying Docker container built for release happily passes along its debug info. The trouble only starts when deployed.

Some interesting things about the project:

  1. We organize our functions via workspaces, so we've defined the profile.release overload in the root Cargo.toml.
  2. We only use Sentry in our library project crate and then use this crate in the other functions; this shouldn't be an issue as evidenced by the fact this works in virtually any environment aside from Lambda itself.
  3. Frustratingly things work as expected locally and during CircleCI builds and even from the build container; just not Lambda itself.
  4. As per Sentry's request we've tried uploading debug symbols manually, but this hasn't really helped.
  5. Sentry complains that libc.6.so is not included in the aforementioned uploaded debug files, but despite this things work in e.g. CircleCI, just again not in Lambda.

I'm wondering if this could be partly to do with the fact that the Lambda executable is packaged and renamed to "bootstrap"? If there's any light you can shed on that piece of things and how it might affect something like this, I'd really appreciate it! :)

serverless version: ^1.51.0

rust-plugin version: ^0.3.6

Out of memory while packaging for local invocation

πŸ› Bug description

When packaging a service for local invocation, serverless runs out of heap memory and aborts.

πŸ€” Expected Behavior

Local invocation should work

πŸ‘Ÿ Steps to reproduce

Serverless: Packaging service...

<--- Last few GCs --->

[3279482:0x358dce0]    61396 ms: Scavenge 1179.7 (1438.5) -> 1171.1 (1443.0) MB, 7.9 / 0.0 ms  (average mu = 0.216, current mu = 0.111) allocation failure 
[3279482:0x358dce0]    62094 ms: Mark-sweep 1185.0 (1443.0) -> 1174.0 (1438.5) MB, 661.8 / 1.3 ms  (average mu = 0.189, current mu = 0.158) allocation failure scavenge might not succeed
[3279482:0x358dce0]    62161 ms: Scavenge 1187.0 (1438.5) -> 1176.8 (1441.5) MB, 8.3 / 0.0 ms  (average mu = 0.189, current mu = 0.158) allocation failure 


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x51e71dbe1d]
Security context: 0x343572c1e6e9 <JSObject>
    1: _process [0x918c3b77bb9] [/home/smag/.config/yarn/global/node_modules/glob/glob.js:~298] [pc=0x51e726b2c9](this=0x3fb631002201 <Glob map = 0x3c1a052e8069>,pattern=0x3b1cc10dc9d9 <JSArray[2]>,index=0,inGlobStar=0x3e54afe828c9 <true>,cb=0x3fb631002289 <JSFunction done (sfi = 0x38603bd6c521)>)
    2: /* anonymous */ [0xd6c9ab719a1] [/home/smag/.config/yarn...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x8fa090 node::Abort() [node]
 2: 0x8fa0dc  [node]
 3: 0xb0039e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xb005d4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xef4ae2  [node]
 6: 0xef4be8 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [node]
 7: 0xf00cc2 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
 8: 0xf015f4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 9: 0xf04261 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node]
10: 0xed3eab v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [node]
11: 0x101d733 v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [node]
12: 0xafdd44 v8::internal::String::Flatten(v8::internal::Handle<v8::internal::String>, v8::internal::PretenureFlag) [node]
13: 0x101e89e v8::internal::StringTable::LookupString(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>) [node]
14: 0x119495b  [node]
15: 0x1196b69 v8::internal::Runtime_KeyedGetProperty(int, v8::internal::Object**, v8::internal::Isolate*) [node]
16: 0x51e71dbe1d 
[1]    3279482 abort (core dumped)  serverless invoke local -f fun -d

NOTE: serverless deploy works fine

🌍 Your environment

Fedora Linux 31.

serverless version:
Framework Core: 1.67.3
Plugin: 3.6.6
SDK: 2.3.0
Components: 2.29.0

rust-plugin version: 0.3.7

Using custom docker tag: 0.2.6-rust-1.42.0

ci: port to GitHub actions

πŸ’‘ Feature description

I've had great experiences with GitHub actions for ci in other projects. It reduces the level of maintenance in that the project and all of its entrapping is consolidated on one platform, github.

πŸ’» Basic example

tbd. find some npm build/test/publish examples

Configuration warning with serverless 2.3.0

πŸ› Bug description

After updating Serverless from 2.0.0 to 2.3.0, I started receiving this warning:
Configuration warning at 'provider.runtime': should be equal to one of the allowed values [dotnetcore2.1, dotnetcore3.1, go1.x, java11, java8, java8.al2, nodejs10.x, nodejs12.x, provided, provided.al2, python2.7, python3.6, python3.7, python3.8, ruby2.5, ruby2.7].

πŸ€” Expected Behavior

There would be no warnings from serverless when using the example config for this plugin.

πŸ‘Ÿ Steps to reproduce

Use provider.runtime = rust in your serverless.yml with the latest Serverless.

🌍 Your environment

serverless version: 2.3.0
rust-plugin version: 0.3.8

Function Not Found - basic-rust-lambda-dev-hello

πŸ› Bug description

Describe your issue in detail.

When I scaffold a fresh project with npx serverless install \ --url https://github.com/softprops/serverless-aws-rust-http \ --name my-new-api then run npm i and then try to invoke locally:

npx serverless invoke -f hello -d "$(cat payload.json)"

It gives me the error, "Function not found".

Serverless Error ---------------------------------------

 Function not found: arn:aws:lambda:us-east-1:954459734159:function:basic-rust-lambda-dev-hello

 Get Support --------------------------------------------
    Docs:          docs.serverless.com
    Bugs:          github.com/serverless/serverless/issues
    Issues:        forum.serverless.com

 Your Environment Information ---------------------------
    OS:                     darwin
    Node Version:           11.15.0
    Serverless Version:     1.47.0

Screen Shot 2020-01-26 at 11 40 56 AM

πŸ€” Expected Behavior

It should have found the function hello.

πŸ‘Ÿ Steps to reproduce

(described above)

🌍 Your environment

serverless version: 1.47.0

rust-plugin version: 0.3.6
Node Version: 11.15.0
OS: darwin

Passing arbitrary `-e` to Docker run

Perhaps this is already possible and I'm missing it: I'm wondering if there's some way of passing through arbitrary -e flags to the Docker run command? In particular this would be nice now that softprops/lambda-rust#31 is merged in--even using a newer tag, there doesn't seem to be a way for library consumers to hook into e.g. a dev build.

Parallel builds

A compilation step is a noticeable thing so maybe we can spawn multiple subprocesses in parallel

fix ci

πŸ› Bug description

it looks like ci started failing after merging #77 with permission errors ironically #77

a separate by related issue should be to answer the question why didn't this fail when the pull request was made

πŸ€” Expected Behavior

ci passed.

πŸ‘Ÿ Steps to reproduce

🌍 Your environment

serverless version:

rust-plugin version:

error: undefined 1

πŸ› Bug description

An error is generated when running the serverless deploy command. I'm trying to run the serverless-aws-rust template.

πŸ‘Ÿ Steps to reproduce

Steps taken:

PS C:\Users\seekr\Desktop> serverless install --url https://github.com/softprops/serverless-aws-rust --name my-new-app
Serverless: Downloading and installing "serverless-aws-rust"...
Serverless: Successfully installed "my-new-app"
PS C:\Users\seekr\Desktop> cd .\my-new-app\
PS C:\Users\seekr\Desktop\my-new-app> npm install

> [email protected] postinstall C:\Users\seekr\Desktop\my-new-app\node_modules\spawn-sync
> node postinstall


> [email protected] postinstall C:\Users\seekr\Desktop\my-new-app\node_modules\serverless
> node ./scripts/postinstall.js

npm WARN my-new-app@ No repository field.
npm WARN my-new-app@ No license field.

added 446 packages from 293 contributors and audited 2111 packages in 15.402s
found 0 vulnerabilities

PS C:\Users\seekr\Desktop\my-new-app> serverless deploy
Serverless: WARNING: Missing "tenant" and "app" properties in serverless.yml. Without these properties, you can not publish the service to the Serverless Platform.
Serverless: Building native Rust hello func...
   Compiling semver-parser v0.7.0
   Compiling libc v0.2.44
   Compiling rand_core v0.3.0
   Compiling void v1.0.2
   Compiling nodrop v0.1.13
   Compiling cfg-if v0.1.6
   Compiling stable_deref_trait v1.1.1
   Compiling byteorder v1.2.7
   Compiling lazy_static v1.2.0
   Compiling scopeguard v0.3.3
   Compiling memoffset v0.2.1
   Compiling lazycell v1.2.1
   Compiling proc-macro2 v0.4.24
   Compiling slab v0.4.1
   Compiling futures v0.1.25
   Compiling unicode-xid v0.1.0
   Compiling num-traits v0.2.6
   Compiling cc v1.0.25
   Compiling itoa v0.4.3
   Compiling num-integer v0.1.39
   Compiling serde v1.0.81
   Compiling httparse v1.3.3
   Compiling ryu v0.2.7
   Compiling fnv v1.0.6
   Compiling indexmap v1.0.2
   Compiling string v0.1.2
   Compiling try-lock v0.2.2
   Compiling rustc-demangle v0.1.9
   Compiling rand_core v0.2.2
   Compiling rand_isaac v0.1.1
   Compiling rand_xorshift v0.1.0
   Compiling rand_hc v0.1.0
   Compiling semver v0.9.0
   Compiling unreachable v1.0.0
   Compiling crossbeam-utils v0.6.2
   Compiling log v0.4.6
   Compiling arrayvec v0.4.8
   Compiling owning_ref v0.4.0
   Compiling tokio-executor v0.1.5
   Compiling backtrace-sys v0.1.24
   Compiling smallvec v0.6.7
   Compiling rustc_version v0.2.3
   Compiling want v0.0.6
   Compiling crossbeam-epoch v0.6.1
   Compiling lock_api v0.1.5
   Compiling tokio-current-thread v0.1.4
   Compiling tokio-timer v0.2.8
   Compiling iovec v0.1.2
   Compiling rand v0.5.5
   Compiling net2 v0.2.33
   Compiling num_cpus v1.8.0
   Compiling time v0.1.40
   Compiling parking_lot_core v0.3.1
   Compiling rand_pcg v0.1.1
   Compiling rand_chacha v0.1.0
   Compiling rand v0.6.1
   Compiling crossbeam-deque v0.6.2
   Compiling quote v0.6.10
   Compiling serde_json v1.0.33
   Compiling bytes v0.4.11
   Compiling mio v0.6.16
   Compiling futures-cpupool v0.1.8
   Compiling chrono v0.4.6
   Compiling syn v0.15.22
   Compiling tokio-io v0.1.10
   Compiling http v0.1.14
   Compiling backtrace v0.3.9
   Compiling mio-uds v0.6.7
   Compiling simple_logger v1.0.1
   Compiling tokio-codec v0.1.1
   Compiling h2 v0.1.14
   Compiling serde_derive v1.0.81
   Compiling parking_lot v0.6.4
   Compiling tokio-reactor v0.1.7
   Compiling tokio-threadpool v0.1.9
   Compiling tokio-uds v0.2.4
   Compiling tokio-tcp v0.1.2
   Compiling tokio-udp v0.1.3
   Compiling tokio-fs v0.1.4
   Compiling tokio v0.1.13
   Compiling hyper v0.12.17
   Compiling lambda_runtime_client v0.1.0
   Compiling lambda_runtime v0.1.0
   Compiling hello v0.1.0 (/code)
    Finished release [optimized] target(s) in 2m 52s
Serverless: Dockerized Rust build encountered an error: undefined 1.

  Error --------------------------------------------------


     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     win32
     Node Version:           11.5.0
     Serverless Version:     1.35.1

Rerunning the serverless deploy command with the SLS_DEBUG env variable set to * yields this stack trace:

Error
    at functions.forEach.funcName (C:\Users\seekr\Desktop\my-new-app\node_modules\serverless-rust\index.js:106:15)
    at Array.forEach (<anonymous>)
    at RustPlugin.build (C:\Users\seekr\Desktop\my-new-app\node_modules\serverless-rust\index.js:90:22)
    at BbPromise.reduce (C:\Users\seekr\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:391:55)
From previous event:
    at PluginManager.invoke (C:\Users\seekr\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:391:22)
    at PluginManager.spawn (C:\Users\seekr\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:409:17)
    at Deploy.BbPromise.bind.then (C:\Users\seekr\AppData\Roaming\npm\node_modules\serverless\lib\plugins\deploy\deploy.js:117:50)
From previous event:
    at Object.before:deploy:deploy [as hook] (C:\Users\seekr\AppData\Roaming\npm\node_modules\serverless\lib\plugins\deploy\deploy.js:107:10)
    at BbPromise.reduce (C:\Users\seekr\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:391:55)
From previous event:
    at PluginManager.invoke (C:\Users\seekr\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:391:22)
    at PluginManager.run (C:\Users\seekr\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:422:17)
    at variables.populateService.then.then (C:\Users\seekr\AppData\Roaming\npm\node_modules\serverless\lib\Serverless.js:157:33)
    at processImmediate (timers.js:632:19)
    at process.topLevelDomainCallback (domain.js:120:23)
From previous event:
    at Serverless.run (C:\Users\seekr\AppData\Roaming\npm\node_modules\serverless\lib\Serverless.js:144:8)
    at serverless.init.then (C:\Users\seekr\AppData\Roaming\npm\node_modules\serverless\bin\serverless:44:28)

🌍 Your environment

Windows 10 x64

serverless version: 1.35.1

rust-plugin version: 0.2.0

packaged artifact broken on latest release on [email protected]

πŸ› Bug description

Describe your issue in detail.

running npx serverless deploy of functions using the latest serverless release (1.39.0) results in the following error

Serverless: Packaging service...
 
  Serverless Error ---------------------------------------
 
  No test-func.zip file found in the package path you provided.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           11.6.0
     Serverless Version:     1.39.0

πŸ€” Expected Behavior

function was deployed as expected with previous releases

πŸ‘Ÿ Steps to reproduce

while testing the latest version for the new invoke local support, a regression test of deployment revealed this error. I'm suspect that something changed in the way serverless resolves artifact paths. an open issue now exists upstream with many users reporting the same issue serverless/serverless#5931

🌍 Your environment

serverless version:

1.39.0

rust-plugin version:

latest

Example with async handler?

πŸ’‘ Feature description

I would like to see examples using async handlers (is it supported already?). The echo, http and multi examples only show sync handlers.

πŸ’» Basic example

Does something like this already work?

fn main() {
    lambda!(handler)
}

async fn handler(
    event: Value,
    _: Context,
) -> Result<Value, HandlerError> {
    f().await?
}

Getting "failed to load source for a dependency" when it's specified by "path"

πŸ› Bug description

When I do sls deploy with this in my Cargo.toml:

headless_chrome = {path = "../headless_chrome/"}

I get this error: https://gist.github.com/atroche/661d7b0df67889635e44317fafb6ec48

And I've also tried changing that path to be absolute.

When I change that line to

headless_chrome = "0.9.0"

Then sls deploy succeeds.

πŸ€” Expected Behavior

It should've built and deployed without an error.

πŸ‘Ÿ Steps to reproduce

Change a dependency to point to a local crate, then do sls deploy.

🌍 Your environment

Your Environment Information ---------------------------
Operating System: linux
Node Version: 10.15.3
Framework Version: 1.51.0
Plugin Version: 1.3.10
SDK Version: 2.1.0

limit what gets published to npm

πŸ’‘ Feature description

the last published tarball looked like this

make publish
npm notice
npm notice πŸ“¦  [email protected]
npm notice === Tarball Contents ===
npm notice 764B   package.json
npm notice 151B   .eslintrc
npm notice 322B   .travis.yml
npm notice 3.3kB  CHANGELOG.md
npm notice 4.9kB  index.js
npm notice 1.1kB  LICENSE
npm notice 22B    Makefile
npm notice 3.4kB  README.md
npm notice 601B   .github/ISSUE_TEMPLATE/bug_report.md
npm notice 334B   .github/ISSUE_TEMPLATE/feature_request.md
npm notice 407B   .github/PULL_REQUEST_TEMPLATE.md
npm notice 48.7kB tests/test-func/Cargo.lock
npm notice 167B   tests/test-func/Cargo.toml
npm notice 96B    tests/test-func/package.json
npm notice 222B   tests/test-func/serverless.yml
npm notice 216B   tests/test-func/src/main.rs
npm notice 14B    tests/test-func/test-event.json
npm notice 1.5kB  tests/test.sh
npm notice === Tarball Details ===
npm notice name:          serverless-rust
npm notice version:       0.3.1
npm notice package size:  15.2 kB
npm notice unpacked size: 66.2 kB
npm notice shasum:        a4767672a6cceb143ed58c31ea4602daae59bfad
npm notice integrity:     sha512-ZpWwNUuEmoxO4[...]G2nJ0EwhpISYA==
npm notice total files:   18
npm notice
+ [email protected]

there's more packaged there that is actually needed

let's limit this to only what is actually needed by consumers

πŸ’» Basic example

"packge: include" does not work?

Hey @softprops!

Thanks for making this awesome project!
Really enjoyed following your documentation, and deploying rust lambdas :)

I stumbled across a minor issue that might have something to do with the plugin.
I'd like the include a statically built executable within the output zip artifact.
Though, for some reason, I wasn't able to do so.

I've tried placing the include keyword both in the "global" serverless.yaml scope like so -

package:
  individually: true
  include:
    - bin/pdftotext

and also in my function scope like so -

functions:
  my-lambda:
  package:
    include:
      - bin/pdftotext

FYI -
I've set dockerPath to ".." since I'm building inside a workspace. Like so -

custom:
  rust:
    dockerPath: ".."

Is it just my setup? Any thoughts?

Use Amazon Linux 2 base OS

πŸ’‘ Feature description

As described here, AL1 has an end-of-life of December 2020.

πŸ’» Basic example

AFAIK, this change should just be to update the string const BASE_RUNTIME = "provided"; to const BASE_RUNTIME = "provided.al2"; and then test.

Respect CARGO_HOME environment variable

πŸ’‘ Feature description

The plugin currently hardcodes ~/.cargo as the cargo home directory to mount into the container. However, the CARGO_HOME environment variable can be used to override this, and the plugin should use that instead if set.

Invoke Local Hangs Forever Before Deploying

Hi, I scaffolded out a new function and would like to run it locally.

I don't want to actually deploy it to aws (maybe I don't even have an aws account).

Personally, I feel that one should be able to run the function locally without needing to connect and deploy to aws... maybe I am missing something here...

The issue though is that when I run the invoke local command the shell just hangs forever. :(

Dockerless build fails to run in Linux

πŸ› Bug description

The artifact mounted in docker image doesn't have an executable flag, so can't be run.
I will submit a PR in minutes

πŸ€” Expected Behavior

artifact should be executable

πŸ‘Ÿ Steps to reproduce

build a dockerless hello world function in Linux, run it locally
serverless invoke local -l -f manager -d '{"name":"foo"}'
image

🌍 Your environment

Arch Linux
serverless version:

Framework Core: 1.74.1
Plugin: 3.6.14
SDK: 2.3.1
Components: 2.31.6

rust-plugin version:
0.3.8

IS_LOCAL env var not being set on local

πŸ› Bug description

According to the AWS - Invoke Local page in the Serverless documentation, running sls invoke local should set the IS_LOCAL environment variable.
I have tried with a NodeJS lambda function and the variable is set, which leads me to believe that the problem comes from this package.

πŸ€” Expected Behavior

The IS_LOCAL environment variable should be set.

πŸ‘Ÿ Steps to reproduce

Having the serverless framework installed:

git clone https://github.com/bernardobelchior/serverless-report
cd serverless-report
npm install
sls invoke local -f hello

🌍 Your environment

serverless version: 1.40.0

rust-plugin version: 0.3.2

OS: Linux

runtime resolution broke in the service 1.41.*

πŸ› Bug description

Describe your issue in detail.

it seems some of the wiring for invoke local changed in serverless 1.41.0 that broke the way this plugin resolves "rust" runtime functions

see for context
softprops/serverless-aws-rust-multi#5

πŸ€” Expected Behavior

upgrading to 1.41.1 should resolve rust functions as expected

πŸ‘Ÿ Steps to reproduce

🌍 Your environment

serverless version:

rust-plugin version:

Can we support `invoke local`

πŸ’‘ Feature description

I'd love to be able to serverless invoke local to do some quick testing

πŸ’» Basic example

My question is more if its even possible

DEFAULT_DOCKER_TAG should be `:latest` by default?

As you know I've modified lambda-rust to play well with a bindgen crate but when I try to deploy/invoke serverless-rust dev cycle, it'll keep pulling the old 0.2.6-rust-1.39.0... I think it would make sense to leave it at latest and let users pass specific docker tags from previous versions if they need so?:

diff --git a/index.js b/index.js
index 1da00f7..66e1188 100644
--- a/index.js
+++ b/index.js
@@ -8,7 +8,7 @@ const { spawnSync } = require("child_process");
 const { homedir } = require("os");
 const path = require("path");

-const DEFAULT_DOCKER_TAG = "0.2.6-rust-1.39.0";
+const DEFAULT_DOCKER_TAG = "latest";
 const RUST_RUNTIME = "rust";
 const BASE_RUNTIME = "provided";
 const NO_OUTPUT_CAPTURE = { stdio: ["ignore", process.stdout, process.stderr] };
diff --git a/package.json b/package.json
index 66d3097..7cee6b7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "serverless-rust",
-  "version": "0.3.7",
+  "version": "0.3.8",
   "description": "Serverless framework plugin for Rustlang applications",
   "main": "index.js",
   "scripts": {

Binary dependencies?

Hello, I’ve been playing around with this plugin and I wonder if you got any idea for how to handle dependencies on dynamic libs? Just add the lib folder if it exist to every binary zip or perhaps something else? I’d like to hear your thoughts on the matter.
Thanks

Cannot deploy selected functions

πŸ› Bug description

Cannot deploy selected functions from sls configuration.

πŸ€” Expected Behavior

Deploying selected functions

πŸ‘Ÿ Steps to reproduce

slss --stage=stage --region=eu-west-1 deploy --config=some-config.yaml --function=echo

result into error:

Error: ENOENT: no such file or directory, open 'C:\Users\abc\IdeaProjects\sls-project\C:\Users\abc\IdeaProjects\sls-project\target\lambda\release\echo.zip'

There is duplicated file path.

🌍 Your environment

Operating System: win32
Node Version: 12.18.3
Framework Version: 1.78.1
Plugin Version: 3.7.0
SDK Version: 2.3.1
Components Version: 2.34.3

rust-plugin version: 0.3.8

`sls deploy` fails due to build error (xml-rs)

πŸ› Bug description

Building an executable (first step of deploy or local invoke) fails due to build error (xml-rs)

πŸ€” Expected Behavior

Should build executable successfully

πŸ‘Ÿ Steps to reproduce

  • Have serverless project with serverless-rust listed as a plugin in the serverless.yml file.
  • Run sls invoke local -f <myFunctionName> OR sls deploy

🌍 Your environment

MacOS Catalina (Building for AWS Lambda)

serverless version: 1.71

rust-plugin version: 3.6 or 3.7 (latest released)

The issue is caused due to docker picking up an older version of the rust compiler (from what I understand) which causes the build failure of xml-rs.
I think this could be fixed with the latest release (4.0) of this plugin. I just checked the CHANGELOG and found that there is a newer version of the docker image being pulled in, in that release.

Allow packaging of static files alongside binary

πŸ’‘ Feature description

It would be nice if it was possible to use the include and exclude package configuration in serverless.yml to choose other files to bundle with the bootstrap binary. For example to include a .env file that is then read by the dotenv crate at runtime.

I am sure that there are other use cases for including files other than the binary but that is the one that sprang to mind.

Failing to build on Windows WSL2 with docker image

πŸ› Bug description

Code fails to compile in the lambda-rust container on Windows WSL2 with Docker. The following error occurs:

Status: Downloaded newer image for softprops/lambda-rust:0.2.7-rust-1.43.1
error: could not find `Cargo.toml` in `/code` or any parent directory
Serverless: Rust build encountered an error: undefined 1.

  Error --------------------------------------------------

  Error:
      at functions.forEach (/home/drodil/code/rustybeer-aws-lambda/node_modules/serverless-rust/index.js:289:15)
      at Array.forEach (<anonymous>)
      at RustPlugin.build (/home/drodil/code/rustybeer-aws-lambda/node_modules/serverless-rust/index.js:269:22)
      at BbPromise.reduce (/home/drodil/code/rustybeer-aws-lambda/node_modules/serverless/lib/classes/PluginManager.js:498:55)
      at tryCatcher (/home/drodil/code/rustybeer-aws-lambda/node_modules/bluebird/js/release/util.js:16:23)
      at Object.gotValue (/home/drodil/code/rustybeer-aws-lambda/node_modules/bluebird/js/release/reduce.js:168:18)
      at Object.gotAccum (/home/drodil/code/rustybeer-aws-lambda/node_modules/bluebird/js/release/reduce.js:155:25)
      at Object.tryCatcher (/home/drodil/code/rustybeer-aws-lambda/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/home/drodil/code/rustybeer-aws-lambda/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/home/drodil/code/rustybeer-aws-lambda/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromise0 (/home/drodil/code/rustybeer-aws-lambda/node_modules/bluebird/js/release/promise.js:649:10)
      at Promise._settlePromises (/home/drodil/code/rustybeer-aws-lambda/node_modules/bluebird/js/release/promise.js:729:18)
      at _drainQueueStep (/home/drodil/code/rustybeer-aws-lambda/node_modules/bluebird/js/release/async.js:93:12)
      at _drainQueue (/home/drodil/code/rustybeer-aws-lambda/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/home/drodil/code/rustybeer-aws-lambda/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/home/drodil/code/rustybeer-aws-lambda/node_modules/bluebird/js/release/async.js:15:14)
      at runCallback (timers.js:705:18)
      at tryOnImmediate (timers.js:676:5)
      at processImmediate (timers.js:658:5)
      at process.topLevelDomainCallback (domain.js:126:23)

Might be related or duplicate to softprops/lambda-rust#8

πŸ€” Expected Behavior

Compiling and deployment works.

πŸ‘Ÿ Steps to reproduce

serverless deploy

The deployment works on MacOS with the same source files.

🌍 Your environment

Your Environment Information ---------------------------

  • Operating System: linux (Ubuntu 18.04 on WSL2)
  • Node Version: 10.19.0
  • Framework Version: 2.4.0 (local)
  • Plugin Version: 4.0.4
  • SDK Version: 2.3.2
  • Components Version: 3.2.1
  • Docker Engine version: v19.03.13

Using nightly Rust

Hi! This project is awesome, so easy to get up and running, so thanks for all your work!

Is it possible to override the version of Rust used to build the functions, e.g. to use a nightly version?

Build in static libraries & musl compilation

πŸ’‘ Feature description

At the moment it is not possible to use serverless-rust if one has a dependency on a library that is not present in the build docker environment (An example is libpq which is needed by Diesel). It is possible to build static binaries in Rust using https://github.com/emk/rust-musl-builder so I ended up bypassing serverless-rust altogether and using that for now, but it'd be nice if some of that could be included in the image you use.

πŸ’» Basic example

It would probably just involve copying a few lines into your dockerfile

improve UX messaging when docker daemon is not accessible

πŸ’‘ Feature description

Currently if docker is not running ( perhaps or installed ) you get the following error

Serverless: Dockerized Rust build encountered an error: undefined 125.

It would be nicer to display a more useful message to help users find their way to success

πŸ’» Basic example

Serverless: Dockerized Rust build encountered an error: It looks like you don't have docker installed. {how to install...}
Serverless: Dockerized Rust build encountered an error: It looks like you don't have docker running. {how to start...}

document story for what offline development looks like

πŸ’‘ Feature description

Local development keeps coming up as a common theme. Figure out and document the story for what this looks like, even if its just documenting how to set up serverless-offline.

πŸ’» Basic example

add a second to the readme that outlines what is needed and how to do this with minimal friction

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.