{"id":13571607,"url":"https://github.com/softprops/serverless-rust","last_synced_at":"2025-04-08T20:17:11.249Z","repository":{"id":39615361,"uuid":"135220798","full_name":"softprops/serverless-rust","owner":"softprops","description":"⚡ 🦀 a serverless framework plugin for rustlang applications","archived":false,"fork":false,"pushed_at":"2023-10-03T17:38:56.000Z","size":1233,"stargazers_count":550,"open_issues_count":31,"forks_count":82,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-01T19:23:51.802Z","etag":null,"topics":["aws","aws-lambda","lambda","rustlang","serverless"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/serverless-rust","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/softprops.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-05-29T00:17:03.000Z","updated_at":"2025-03-26T03:19:23.000Z","dependencies_parsed_at":"2024-01-14T03:49:58.627Z","dependency_job_id":"414d52ce-0e37-4fc1-b476-5abeb3efb0ae","html_url":"https://github.com/softprops/serverless-rust","commit_stats":{"total_commits":232,"total_committers":13,"mean_commits":"17.846153846153847","dds":"0.11206896551724133","last_synced_commit":"c5d5e711fc73682d003879474a53bf7672f02ec4"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fserverless-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fserverless-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fserverless-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fserverless-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softprops","download_url":"https://codeload.github.com/softprops/serverless-rust/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247919002,"owners_count":21018046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-lambda","lambda","rustlang","serverless"],"created_at":"2024-08-01T14:01:03.776Z","updated_at":"2025-04-08T20:17:11.230Z","avatar_url":"https://github.com/softprops.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n   ⚡ 🦀\n\u003c/div\u003e\n\n\u003ch1 align=\"center\"\u003e\n  serverless-rust\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n   A ⚡ \u003ca href=\"https://www.serverless.com/framework/docs/\"\u003eServerless framework\u003c/a\u003e ⚡ plugin for \u003ca href=\"https://www.rust-lang.org/\"\u003eRustlang\u003c/a\u003e applications\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/softprops/serverless-rust/actions\"\u003e\n    \u003cimg alt=\"GitHub actions build badge\" src=\"https://github.com/softprops/serverless-rust/workflows/Main/badge.svg\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/serverless-rust\"\u003e\n    \u003cimg alt=\"npm release badge\" src=\"https://img.shields.io/npm/v/serverless-rust.svg\"/\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n## 📦 Install\n\nInstall the plugin inside your serverless project with npm.\n\n```sh\n$ npm i -D serverless-rust\n```\n💡The `-D` flag adds it to your development dependencies in npm speak\n\n💡 This plugin assumes you are building Rustlang lambdas targeting the AWS Lambda \"provided\" runtime. The [AWS Lambda Rust Runtime](https://github.com/awslabs/aws-lambda-rust-runtime) makes this easy.\n\nAdd the following to your serverless project's `serverless.yml` file\n\n```yaml\nservice: demo\nprovider:\n  name: aws\n  runtime: rust\nplugins:\n  # this registers the plugin\n  # with serverless\n  - serverless-rust\n# creates one artifact for each function\npackage:\n  individually: true\nfunctions:\n  test:\n    # handler value syntax is `{cargo-package-name}.{bin-name}`\n    # or `{cargo-package-name}` for short when you are building a\n    # default bin for a given package.\n    handler: your-cargo-package-name\n    events:\n      - http:\n          path: /test\n          method: GET\n```\n\n\u003e 💡 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.\n\nThe 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.\n\n## 🖍️ customize\n\nYou can optionally adjust the default settings of the dockerized build env using\na custom section of your serverless.yaml configuration\n\n```yaml\ncustom:\n  # this section customizes of the default\n  # serverless-rust plugin settings\n  rust:\n    # flags passed to cargo\n    cargoFlags: '--features enable-awesome'\n    # custom docker tag\n    dockerTag: 'some-custom-tag'\n    #  custom docker image\n    dockerImage: 'dockerUser/dockerRepo'\n```\n\n### 🥼 (experimental) local builds\n\nWhile it's useful to have a build environment that matches your deployment\nenvironment, dockerized builds come with some notable tradeoffs.\n\nThe external dependency on docker itself often causes friction as an added dependency to your build.\n\nDepending 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.\n\nIf you wish to build lambda's locally, use the `dockerless` configuration setting. \n\n```diff\ncustom:\n  # this section allows for customization of the default\n  # serverless-rust plugin settings\n  rust:\n    # flags passed to cargo\n    cargoFlags: '--features enable-awesome'\n    # experimental! when set to true, artifacts are built locally outside of docker\n+   dockerless: true\n\n    # when using local builds (dockerless), optionally provide a different target and linker for the compiler\n    # for example, allow local running on ARM macs\n    target: aarch64-apple-darwin\n    linker: clang\n```\n\nThe 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.\n\nThis 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](https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html). The aim is that in future releases, this might become the default behavior.\n\nIn order to use this mode its expected that you install the `x86_64-unknown-linux-musl` target on all platforms locally with\n\n```sh\n$ rustup target add x86_64-unknown-linux-musl\n```\n\nOn linux platforms, you will need to install musl-tools\n\n```sh\n$ sudo apt-get update \u0026\u0026 sudo apt-get install -y musl-tools\n```\n\nOn Mac OSX, you will need to install a MUSL cross compilation toolchain\n\n```sh\n$ brew install filosottile/musl-cross/musl-cross\n```\n\nUsing MUSL comes with some other notable tradeoffs. One of which is complications that arise when depending on dynamically linked dependencies.\n\n* With OpenSSL bindings which you can safely replace is with [rustls](https://github.com/ctz/rustls) or [vendor it](https://docs.rs/openssl/0.10.29/openssl/#vendored)\n* Other limitations are noted [here](https://github.com/KodrAus/rust-cross-compile#limitations).\n\nIf you find other MUSL specific issues, please report them by [opening an issue](https://github.com/softprops/serverless-rust/issues/new?template=bug_report.md).\n\n### 🎨 Per function customization\n\nIf your serverless project contains multiple functions, you may sometimes\nneed to customize the options above at the function level. You can do this\nby defining a `rust` key with the same options inline in your function\nspecification.\n\n```yaml\nfunctions:\n  test:\n    rust:\n      # function specific flags passed to cargo\n      cargoFlags: '--features enable-awesome'\n    # handler value syntax is `{cargo-package-name}.{bin-name}`\n    # or `{cargo-package-name}` for short when you are building a\n    # default bin for a given package.\n    handler: your-cargo-package-name\n    events:\n      - http:\n          path: /test\n          method: GET\n```\n\n## 🤸 usage\n\nEvery [serverless workflow command](https://serverless.com/framework/docs/providers/aws/guide/workflow/) should work out of the box.\n\n### invoke your lambdas locally\n\n```sh\n$ npx serverless invoke local -f hello -d '{\"hello\":\"world\"}'\n```\n\n### deploy your lambdas to the cloud\n\n```sh\n$ npx serverless deploy\n```\n\n### invoke your lambdas in the cloud directly\n\n```sh\n$ npx serverless invoke -f hello -d '{\"hello\":\"world\"}'\n```\n\n### view your lambdas logs\n\n```sh\n$ npx serverless logs -f hello\n```\n\n## 🏗️ serverless templates\n\n### ^0.2.*\n\n* a minimal echo application - https://github.com/softprops/serverless-aws-rust\n* a minimal http application - https://github.com/softprops/serverless-aws-rust-http\n* a minimal multi-function application - https://github.com/softprops/serverless-aws-rust-multi\n* a minimal apigateway websocket application - https://github.com/softprops/serverless-aws-rust-websockets\n* a minimal kinesis application - https://github.com/softprops/serverless-aws-rust-kinesis\n\n### 0.1.*\n\nOlder versions targeted the python 3.6 AWS Lambda runtime and [rust crowbar](https://github.com/ilianaw/rust-crowbar) and [lando](https://github.com/softprops/lando) applications\n\n* lando api gateway application - https://github.com/softprops/serverless-lando\n* multi function lando api gateway application - https://github.com/softprops/serverless-multi-lando\n* crowbar cloudwatch scheduled lambda application - https://github.com/softprops/serverless-crowbar\n\nDoug Tangren (softprops) 2018-2019\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftprops%2Fserverless-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftprops%2Fserverless-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftprops%2Fserverless-rust/lists"}