darrenmeehan / get-photos-lambda

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

get-photos-lambda

AWS Lambda to retrieves images from Photos DB.

It is intended for this to be an integration an HTTP API with DynamoDB.

Test

Currently, there are no tests for this code. Pure cowboy stuff at the moment!

cargo test

Build

To build the Rust binary

$ cargo build --release

Build on MacOS

$ cargo build --release --target x86_64-unknown-linux-musl

To build the AWS Lambda zip file

$ cp ./target/x86_64-unknown-linux-musl/release/get-photos-lambda ./bootstrap && zip lambda.zip bootstrap && rm bootstrap

Deployment

Create AWS Lambda for the first time

$ aws lambda create-function --function-name get-photos \
  --handler not.used.in.rust \
  --zip-file fileb://./lambda.zip \
  --runtime provided \
  --role arn:aws:iam::409276471434:role/get-photos-lambda \
  --environment Variables={RUST_BACKTRACE=1} \
  --tracing-config Mode=Active

To update the code of an existing AWS Lambda

$ aws lambda update-function-code --function-name get-photos \
--zip-file fileb://./lambda.zip

cargo aws-lambda

To simplify the building and deployment use the following tool.

$ cargo install cargo-aws-lambda

$ cargo aws-lambda {your aws function's full ARN} {your-binary-name}

For more information view

Invoke AWS Lambda

To test your deployed AWS Lambda works correctly

$ aws lambda invoke --function-name get-photos \
  --cli-binary-format raw-in-base64-out \
  --payload '{"firstName": "world"}' \
  output.json
$ cat output.json  # Prints: {"message":"Hello, world!"}

About


Languages

Language:Rust 83.7%Language:Shell 15.3%Language:Makefile 0.9%