{"id":22148664,"url":"https://github.com/kaicoh/serverless-rust-plugin","last_synced_at":"2025-07-26T02:32:47.717Z","repository":{"id":63446950,"uuid":"567059207","full_name":"kaicoh/serverless-rust-plugin","owner":"kaicoh","description":"A Serverless Framework plugin for Rust using Cargo Lambda.","archived":false,"fork":false,"pushed_at":"2023-11-29T11:20:54.000Z","size":2262,"stargazers_count":7,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-16T10:07:05.091Z","etag":null,"topics":["aws","aws-lambda","lambda","rust","serverless","serverless-framework","serverless-plugin"],"latest_commit_sha":null,"homepage":"","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/kaicoh.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2022-11-17T01:24:16.000Z","updated_at":"2024-05-17T21:06:52.000Z","dependencies_parsed_at":"2023-11-29T12:28:50.100Z","dependency_job_id":null,"html_url":"https://github.com/kaicoh/serverless-rust-plugin","commit_stats":{"total_commits":150,"total_committers":2,"mean_commits":75.0,"dds":0.00666666666666671,"last_synced_commit":"995569759cb860bd0db73e0c55806317938989ca"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaicoh%2Fserverless-rust-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaicoh%2Fserverless-rust-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaicoh%2Fserverless-rust-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaicoh%2Fserverless-rust-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaicoh","download_url":"https://codeload.github.com/kaicoh/serverless-rust-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227645496,"owners_count":17798337,"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","rust","serverless","serverless-framework","serverless-plugin"],"created_at":"2024-12-01T23:29:02.926Z","updated_at":"2024-12-01T23:29:03.961Z","avatar_url":"https://github.com/kaicoh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# serverless-rust-plugin\n\n[![Serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)\n[![main](https://github.com/kaicoh/serverless-rust-plugin/actions/workflows/test.yml/badge.svg)](https://github.com/kaicoh/serverless-rust-plugin/actions)\n[![Coverage Status](https://coveralls.io/repos/github/kaicoh/serverless-rust-plugin/badge.svg?branch=main)](https://coveralls.io/github/kaicoh/serverless-rust-plugin?branch=main)\n\nA [Serverless Framework](https://www.serverless.com/) plugin for [Rust](https://www.rust-lang.org/) using [Cargo Lambda](https://www.cargo-lambda.info/)\n\n## Requirement\n\nThis plugin has peer dependency, `serverless framework v3`.\n\n## Installation\n\nRun this command.\n\n```\n$ npm install --save-dev serverless-rust-plugin\n```\n\nAnd add the following to your serverless.yml file\n\n```\nprovider:\n  name: aws\n  runtime: provided.al2\n  # this plugin reads this property and passes it to cargo lambda.\n  # default is x86_64.\n  architecture: arm64\nplugins\n  - serverless-rust-plugin\nfunctions:\n  hello:\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```\n\nIn [documents of AWS Lambda Runtime](https://github.com/awslabs/aws-lambda-rust-runtime) the handler is set to be `bootstrap`. This plugin renames the handler in deployment process so you don't have to worry about it.\n\n## Example projects\n\nSee [examples](examples).\n\n## Usage\n\n### Deployment\n\n```\n$ serverless deploy\n```\n\nBy default this plugin uses docker container to build. Make sure you have a docker daemon running. But if your local machine installs cargo lambda, you can use it by the following configuration.\n\n#### Configuration for build\n\n```\nprovider:\n  name: aws\n  architecture: arm64\n\ncustom:\n  rust:\n    cargoLambda:\n      docker: false\n      profile: debug\n```\n\n| option | path in serverless.yml | values | description |\n| :--- | :--- | :---: | :--- |\n| architecture | provider.architecture | x86_64, arm64 | The architecture cargo lambda compiles for. default is x86_64. |\n| docker | custom.rust.cargoLambda.docker | boolean | Use docker to compile or not. If true, this plugin uses [cargo-lambda/cargo-lambda](https://github.com/cargo-lambda/cargo-lambda/pkgs/container/cargo-lambda) otherwise cargo lambda in your local machine. |\n| profile | custom.rust.cargoLambda.profile | release, debug | The mode cargo lambda compiles. default is release. |\n\n### Local Test\n\nUsing docker, this plugin has some commands for testing your lambda functions locally. These commands use docker regardless of the setting for cargo lambda build.\n(Local testing is nothing to do with `custom.rust.cargoLambda.docker` in serverless.yml.) For more info, see [this](docs).\n\n```\nservice: my-service\n\nprovider:\n  name: aws\n  runtime: provided.al2\n  architecture: arm64\n\nplugins\n  - serverless-rust-plugin\n\ncustom:\n  rust:\n    cargoLambda:\n      docker: false\n    local:\n      envFile: .env.global\n      dockerArgs: --network my-network-global\n\nfunctions:\n  rustFunc0:\n    handler: cargo-package.bin0\n    rust:\n      port: 8080\n      envFile: .env.local\n      dockerArgs: --network my-network-local\n\n  rustFunc1:\n    handler: cargo-package.bin1\n\n  nonRustFunc:\n    handler: non-of-the-above\n```\n\n#### rust:start\n\nStart the docker container according to the configuration in serverless.yml and show the status for each container. For more information about configurations and options for this command see [this](docs/rust:start).\n\n```\n$ serverless rust:start\n...\n    Finished release [optimized] target(s) in 0.83s\n\n╔════════════╤══════════════════════╤═════════╤═══════════════════════════╗\n║ FUNCTION   │ CONTAINER NAME       │ STATUS  │ PORTS                     ║\n╟────────────┼──────────────────────┼─────────┼───────────────────────────╢\n║ rustFunc0  │ my-service_rustFunc0 │ running │ 0.0.0.0:8080 -\u003e 8080/tcp  ║\n╟────────────┼──────────────────────┼─────────┼───────────────────────────╢\n║ rustFunc1  │ my-service_rustFunc1 │ running │ 0.0.0.0:60702 -\u003e 8080/tcp ║\n╚════════════╧══════════════════════╧═════════╧═══════════════════════════╝\n```\n\n#### rust:ps\n\nShow the status for each container. For more information about configurations and options for this command see [this](docs/rust:ps).\n\n```\n$ serverless rust:ps\n\n╔════════════╤══════════════════════╤═════════╤═══════════════════════════╗\n║ FUNCTION   │ CONTAINER NAME       │ STATUS  │ PORTS                     ║\n╟────────────┼──────────────────────┼─────────┼───────────────────────────╢\n║ rustFunc0  │ my-service_rustFunc0 │ running │ 0.0.0.0:8080 -\u003e 8080/tcp  ║\n╟────────────┼──────────────────────┼─────────┼───────────────────────────╢\n║ rustFunc1  │ my-service_rustFunc1 │ running │ 0.0.0.0:60702 -\u003e 8080/tcp ║\n╚════════════╧══════════════════════╧═════════╧═══════════════════════════╝\n```\n\n#### rust:invoke\n\nInvoke lambda function and show output. For more information about configurations and options for this command see [this](docs/rust:invoke).\n\n```\n$ serverless rust:invoke -f rustFunc0 -d '{\"firstName\":\"Mary\"}'\n...\n    Finished release [optimized] target(s) in 0.39s\n\n{\"message\":\"Hi, Mary!\"}\n```\n\n#### rust:logs\n\nShow logs of lambda functions. For more information about configurations and options for this command see [this](docs/rust:logs).\n\n```\n$ serverless rust:logs\nrustFunc1  | START RequestId: 67394de9-1577-4ebd-be58-ba4237b71ef1 Version: $LATEST\nrustFunc1  | END RequestId: 67394de9-1577-4ebd-be58-ba4237b71ef1\nrustFunc1  | REPORT RequestId: 67394de9-1577-4ebd-be58-ba4237b71ef1\tInit Duration: 4.09 ms\tDuration: 237.96 ms\tBilled Duration: 238 ms\tMemory Size: 3008 MB\tMax Memory Used: 3008 MB\nrustFunc0  | START RequestId: e85bd375-77cf-411a-b31b-08170a454a62 Version: $LATEST\nrustFunc0  | END RequestId: e85bd375-77cf-411a-b31b-08170a454a62\nrustFunc0  | REPORT RequestId: e85bd375-77cf-411a-b31b-08170a454a62\tInit Duration: 4.28 ms\tDuration: 240.70 ms\tBilled Duration: 241 ms\tMemory Size: 3008 MB\tMax Memory Used: 3008 MB\nrustFunc0  | START RequestId: 0a3e927b-8ff2-456a-9691-5003b7e1004e Version: $LATEST\nrustFunc0  | END RequestId: 0a3e927b-8ff2-456a-9691-5003b7e1004e\nrustFunc0  | REPORT RequestId: 0a3e927b-8ff2-456a-9691-5003b7e1004e\tDuration: 40.65 ms\tBilled Duration: 41 ms\tMemory Size: 3008 MB\tMax Memory Used: 3008 MB\n```\n\n#### rust:stop\n\nStop containers and show the status. For more information about configurations and options for this command see [this](docs/rust:stop).\n\n```\n$ serverless rust:stop\n\n╔════════════╤════════════════╤═══════════╤═══════╗\n║ FUNCTION   │ CONTAINER NAME │ STATUS    │ PORTS ║\n╟────────────┼────────────────┼───────────┼───────╢\n║ rustFunc0  │                │ not exist │       ║\n╟────────────┼────────────────┼───────────┼───────╢\n║ rustFunc1  │                │ not exist │       ║\n╚════════════╧════════════════╧═══════════╧═══════╝\n```\n\n## License\n\nThis software is released under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaicoh%2Fserverless-rust-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaicoh%2Fserverless-rust-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaicoh%2Fserverless-rust-plugin/lists"}