Skip to content

Commit 8f026a0

Browse files
authored
Documentation fixes with some linting (awslabs#219)
1 parent 4f1d44e commit 8f026a0

File tree

5 files changed

+26
-15
lines changed

5 files changed

+26
-15
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
/target
22
/.cargo
3-
lambda-runtime/libtest.rmeta
3+
lambda-runtime/libtest.rmeta
4+
5+
# Built AWS Lambda zipfile
6+
lambda.zip
7+
8+
# output.json from example docs
9+
output.json

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Rust Runtime for AWS Lambda
22

3-
[![Build Status](https://travis-ci.org/awslabs/aws-lambda-rust-runtime.svg?branch=master)](https://travis-ci.org/awslabs/aws-lambda-rust-runtime)
4-
53
This package makes it easy to run AWS Lambda Functions written in Rust. This workspace includes multiple crates:
64

75
- [![Docs](https://docs.rs/lambda_runtime_client/badge.svg)](https://docs.rs/lambda_runtime_client) **`lambda-runtime-client`** is a client SDK for the Lambda Runtime APIs. You probably don't need to use this crate directly!
@@ -62,21 +60,21 @@ There are currently multiple ways of building this package: manually, and the [S
6260
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.
6361

6462
```bash
65-
$ cargo build -p lambda_runtime --example basic --release
63+
$ cargo build -p lambda --example hello --release
6664
```
6765

6866
For a custom runtime, AWS Lambda looks for an executable called `bootstrap` in the deployment package zip. Rename the generated `basic` executable to `bootstrap` and add it to a zip archive.
6967

7068
```bash
71-
$ cp ./target/release/examples/basic ./bootstrap && zip lambda.zip bootstrap && rm bootstrap
69+
$ cp ./target/release/examples/hello ./bootstrap && zip lambda.zip bootstrap && rm bootstrap
7270
```
7371

7472
Now that we have a deployment package (`lambda.zip`), we can use the [AWS CLI](https://aws.amazon.com/cli/) to create a new Lambda function. Make sure to replace the execution role with an existing role in your account!
7573

7674
```bash
7775
$ aws lambda create-function --function-name rustTest \
7876
--handler doesnt.matter \
79-
--zip-file file://./lambda.zip \
77+
--zip-file fileb://./lambda.zip \
8078
--runtime provided \
8179
--role arn:aws:iam::XXXXXXXXXXXXX:role/your_lambda_execution_role \
8280
--environment Variables={RUST_BACKTRACE=1} \
@@ -92,6 +90,9 @@ $ aws lambda invoke --function-name rustTest \
9290
$ cat output.json # Prints: {"message":"Hello, world!"}
9391
```
9492

93+
**Note:** `--cli-binary-format raw-in-base64-out` is a required
94+
argument when using the AWS CLI version 2. [More Information](https://docs.aws.amazon.com/cli/latest/userguide/cliv2-migration.html#cliv2-migration-binaryparam)
95+
9596
#### Serverless Framework
9697

9798
Alternatively, you can build a Rust-based Lambda function declaratively using the [Serverless framework Rust plugin](https://github.com/softprops/serverless-rust).

lambda/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "lambda"
33
version = "0.1.0"
44
authors = ["David Barsky <[email protected]>"]
5+
description = "AWS Lambda Runtime."
56
edition = "2018"
67

78
[features]

lambda/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ async fn next_event(req: &Request<Body>) -> Result<Response<Body>, Error> {
111111

112112
let rsp = NextEventResponse {
113113
request_id: "8476a536-e9f4-11e8-9739-2dfe598c3fcd",
114-
deadline: 1542409706888,
114+
deadline: 1_542_409_706_888,
115115
arn: "arn:aws:lambda:us-east-2:123456789012:function:custom-runtime",
116116
trace_id: "Root=1-5bef4de7-ad49b0e87f6ef6c87fc2e700;Parent=9a9197af755a6419",
117117
body: serde_json::to_vec(&body)?,

lambda/src/lib.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33

44
//! The official Rust runtime for AWS Lambda.
55
//!
6-
//! There are two mechanisms of defining a Lambda function:
7-
//! 1. The `#[lambda]` attribute, which generates the boilerplate needed to
8-
//! to launch and run a Lambda function. The `#[lambda]` attribute _must_
9-
//! be placed on an asynchronous main funtion. However, asynchronous main
10-
//! funtions are not legal valid Rust, which means that a crate like
11-
//! [Runtime](https://github.com/rustasync/runtime) must be used. A main function
12-
//! decorated using `#[lamdba]`
6+
//! There are two mechanisms available for defining a Lambda function:
7+
//! 1. The `#[lambda]` attribute, which generates the boilerplate to
8+
//! to launch and run a Lambda function.
9+
//!
10+
//! The `#[lambda]` attribute _must_ be placed on an asynchronous main function.
11+
//! However, as asynchronous main functions are not legal valid Rust
12+
//! this means that the main function must also be decorated using a
13+
//! `#[tokio::main]` attribute macro. This is available from
14+
//! the [tokio](https://github.com/tokio-rs/tokio) crate.
15+
//!
1316
//! 2. A type that conforms to the [`Handler`] trait. This type can then be passed
1417
//! to the the `lambda::run` function, which launches and runs the Lambda runtime.
1518
//!
@@ -49,7 +52,7 @@ use std::{
4952
mod client;
5053
mod requests;
5154
mod simulated;
52-
/// Types availible to a Lambda function.
55+
/// Types available to a Lambda function.
5356
mod types;
5457

5558
use requests::{EventCompletionRequest, EventErrorRequest, IntoRequest, NextEventRequest};

0 commit comments

Comments
 (0)