You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Feature flags for lambda_http
Add feature flags to lambda_http so consumer can decide which service their events come from. This makes compilation much faster when you don't put the same Lambda function behind multiple services.
Signed-off-by: David Calavera <[email protected]>
* Rename features to match AWS documentation.
Use the names present in the API GW documentation to differentiate the APIs.
Signed-off-by: David Calavera <[email protected]>
* Fix file names
Signed-off-by: David Calavera <[email protected]>
* Mention Function URLs in the readme.
Signed-off-by: David Calavera <[email protected]>
* Fix typo.
Signed-off-by: David Calavera <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+24-6
Original file line number
Diff line number
Diff line change
@@ -330,12 +330,6 @@ You can read more about how [cargo lambda start](https://github.com/calavera/car
330
330
331
331
Lambdas can be run and debugged locally using a special [Lambda debug proxy](https://github.com/rimutaka/lambda-debug-proxy) (a non-AWS repo maintained by @rimutaka), which is a Lambda function that forwards incoming requests to one AWS SQS queue and reads responses from another queue. A local proxy running on your development computer reads the queue, calls your Lambda locally and sends back the response. This approach allows debugging of Lambda functions locally while being part of your AWS workflow. The Lambda handler code does not need to be modified between the local and AWS versions.
332
332
333
-
## `lambda_runtime`
334
-
335
-
`lambda_runtime` is a library for authoring reliable and performant Rust-based AWS Lambda functions. At a high level, it provides `lambda_runtime::run`, a function that runs a `tower::Service<LambdaEvent>`.
336
-
337
-
To write a function that will handle request, you need to pass it through `service_fn`, which will convert your function into a `tower::Service<LambdaEvent>`, which can then be run by `lambda_runtime::run`.
338
-
339
333
## AWS event objects
340
334
341
335
This project does not currently include Lambda event struct definitions. Instead, the community-maintained [`aws_lambda_events`](https://crates.io/crates/aws_lambda_events) crate can be leveraged to provide strongly-typed Lambda event structs. You can create your own custom event objects and their corresponding structs as well.
`lambda_http` is a wrapper for HTTP events coming from three different services, Amazon Load Balancer (ALB), Amazon Api Gateway (APIGW), and AWS Lambda Function URLs. Amazon Api Gateway can also send events from three different endpoints, REST APIs, HTTP APIs, and WebSockets. `lambda_http` transforms events from all these sources into native `http::Request` objects, so you can incorporate Rust HTTP semantics into your Lambda functions.
378
+
379
+
By default, `lambda_http` compiles your function to support any of those services. This increases the compile time of your function because we have to generate code for all the sources. In reality, you'll usually put a Lambda function only behind one of those sources. You can choose which source to generate code for with feature flags.
380
+
381
+
The available features flags for `lambda_http` are the following:
382
+
383
+
-`alb`: for events coming from [Amazon Elastic Load Balancer](https://aws.amazon.com/elasticloadbalancing/).
384
+
-`apigw_rest`: for events coming from [Amazon API Gateway Rest APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-rest-api.html).
385
+
-`apigw_http`: for events coming from [Amazon API Gateway HTTP APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html) and [AWS Lambda Function URLs](https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html).
386
+
-`apigw_websockets`: for events coming from [Amazon API Gateway WebSockets](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api.html).
387
+
388
+
If you only want to support one of these sources, you can disable the default features, and enable only the source that you care about in your package's `Cargo.toml` file. Substitute the dependency line for `lambda_http` for the snippet below, changing the feature that you want to enable:
389
+
390
+
```toml
391
+
[dependencies.lambda_http]
392
+
version = "0.5.3"
393
+
default-features = false
394
+
features = ["apigw_rest"]
395
+
```
396
+
397
+
This will make your function compile much faster.
398
+
381
399
## Supported Rust Versions (MSRV)
382
400
383
401
The AWS Lambda Rust Runtime requires a minimum of Rust 1.54, and is not guaranteed to build on compiler versions earlier than that.
0 commit comments