Skip to content

Commit 7ee965d

Browse files
softpropsdavidbarsky
authored andcommitted
documented better developer experience (#47)
* documented better developer experience * consistent shell example fmt * teach fewer tools * better description of what deploy does * move one-time-cmd to one time run block * links to serverless application templates * fix link * address pr copy feedback * colon after source
1 parent 545f653 commit 7ee965d

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

README.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ fn my_handler(event: GreetingEvent, ctx: Context) -> Result<GreetingResponse, Ha
5353
}
5454
```
5555

56-
The code above is the same as the [basic example](https://github.com/awslabs/aws-lambda-rust-runtime/tree/master/lambda-runtime/examples/basic.rs) in the `lambda-runtime` crate. To deploy the basic sample as a Lambda function, we first build it with `cargo`. Since Lambda uses Amazon Linux, you'll need to target your executable for an `x86_64-linux` platform.
56+
The code above is the same as the [basic example](https://github.com/awslabs/aws-lambda-rust-runtime/tree/master/lambda-runtime/examples/basic.rs) in the `lambda-runtime` crate.
57+
58+
### Deployment
59+
60+
There are currently multiple ways of building this package: manually, and the [Serverless framework](https://serverless.com/framework/).
61+
62+
#### AWS CLI
63+
64+
To deploy the basic sample as a Lambda function using the [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html), we first need to manually build it with [`cargo`](https://doc.rust-lang.org/cargo/). Since Lambda uses Amazon Linux, you'll need to target your executable for an `x86_64-linux` platform.
5765

5866
```bash
5967
$ cargo build -p lambda_runtime --example basic --release
@@ -86,6 +94,41 @@ $ aws lambda invoke --function-name rustTest \
8694
$ cat output.json # Prints: {"message":"Hello, world!"}
8795
```
8896

97+
#### Serverless Framework
98+
99+
Alternatively, you can build a Rust-based Lambda function declaratively using the [Serverless framework Rust plugin](https://github.com/softprops/serverless-rust).
100+
101+
A number of getting started Serverless application templates exist to get you up and running quickly
102+
103+
* a minimal [echo function](https://github.com/softprops/serverless-aws-rust) to demonstrate what the smallest Rust function setup looks like
104+
* a minimal [http function](https://github.com/softprops/serverless-aws-rust-http) to demonstrate how to interface with API Gateway using Rust's native [http](https://crates.io/crates/http) crate (note this will a git dependency until 0.2 is published)
105+
* a combination [multi function service](https://github.com/softprops/serverless-aws-rust-multi) to demonstrate how to set up a services with multiple independent functions
106+
107+
Assuming your host machine has a relatively recent version of node, you [won't need to install any host-wide serverless dependencies](https://blog.npmjs.org/post/162869356040/introducing-npx-an-npm-package-runner). To get started, run the following commands to create a new lambda Rust application
108+
and install project level dependencies.
109+
110+
```bash
111+
$ npx serverless install \
112+
--url https://github.com/softprops/serverless-aws-rust \
113+
--name my-new-app \
114+
&& cd my-new-app \
115+
&& npm install --silent
116+
```
117+
118+
Deploy it using the standard serverless workflow
119+
120+
```bash
121+
# build, package, and deploy service to aws lambda
122+
$ npx serverless deploy
123+
```
124+
125+
Invoke it using serverless framework or a configured AWS integrated trigger source:
126+
127+
```bash
128+
$ npx serverless invoke -f hello -d '{"foo":"bar"}'
129+
```
130+
131+
89132
## lambda-runtime-client
90133

91134
Defines the `RuntimeClient` trait and provides its `HttpRuntimeClient` implementation. The client fetches events and returns output as `Vec<u8>`.

0 commit comments

Comments
 (0)