Crates.io | gafe |
lib.rs | gafe |
version | 1.0.2 |
source | src |
created_at | 2022-03-15 22:40:03.964868 |
updated_at | 2022-04-08 21:16:56.889053 |
description | Get As a Function, Eh! |
homepage | |
repository | https://github.com/pietro/gafe |
max_upload_size | |
id | 550749 |
size | 52,037 |
An AWS Lambda that will do HTTP Get requests for you.
Yes.
Send a JSON payload to the lambda with headers
and uri
and the code does request for the uri
using your headers
. You get back a JSON with the AWS Request ID of the lambda invocation, the HTTP status and the response headers. The response body is base64 encoded.
{
"uri": "https://example.org",
"headers": {
"x-foo": "bar"
}
}
{
"req_id": "dd50c345-8373-4145-8883-1717f2da7f75",
"status": 200,
"headers": {
"accept-ranges": "bytes",
"vary": "Accept-Encoding"
...
},
"body": "PCF..."
}
The Lambda Rust Runtime has detailed information on how to buld and deploy rust functions. But the quick and dirty is:
rustserverless/lambda-rust
docker image:docker run --rm -u $(id -u):$(id -g) \
-e BIN=gafe \
-v ${PWD}:/code \
-v ${HOME}/.cargo/registry:/cargo/registry \
-v ${HOME}/.cargo/git:/cargo/git \
rustserverless/lambda-rust:latest
You can use the image rustserverless/lambda-rust:latest-arm64
if your CPU is a 64-bit ARM.
aws lambda create-function --function-name rustTest \
--handler bootstrap \
--zip-file fileb://./target/lambda/gafe/bootstrap.zip \
--runtime provided.al2
--role arn:aws:iam::XXXXXXXXXXXXX:role/your_lambda_execution_role \
--environment Variables={LOG_LEVEL=info}
$ aws lambda invoke
--cli-binary-format raw-in-base64-out \
--function-name rustTest \
--payload '{"uri": "https://example.org", "headers": {"x-foo":"bar"}}' \
output.json
$ cat output.json # Prints the full non-formated version of the example response from above
Payload limit (request and response):
6 MB (synchronous) 256 KB (asynchronous)