GithubHelp home page GithubHelp logo

rust-lambda-x-db's Introduction

AWS Lambda DynamoDB Logger

This Rust project defines an AWS Lambda function designed to log commands received through events into an Amazon DynamoDB table and, optionally, fetch and display the contents of this table. The Lambda function is built using lambda_runtime for the Rust runtime and rusoto_dynamodb for interacting with DynamoDB.

Features

  • Log Commands: Logs each command received through a Lambda event to a DynamoDB table and AWS cloudwatch. AWS X-Ray is also enabled.
  • Print Database Contents: On receiving a specific command (print_db), the Lambda function scans the specified DynamoDB table and returns its contents as part of the response message.

Requirements

  • Rust and Cargo
  • AWS CLI configured with appropriate access rights
  • An existing Amazon DynamoDB table

Setup

DynamoDB Table

Ensure you have a DynamoDB table created with the name my-table and a primary key named request_id.

Deployment Package

Build your Lambda function package by compiling the Rust project:

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

Then, create a deployment package by zipping the compiled binary:

zip -j rust_lambda.zip ./target/x86_64-unknown-linux-musl/release/bootstrap

Lambda Function

Create an AWS Lambda function specifying the runtime as provided and upload the rust_lambda.zip as the function code. Ensure the Lambda function's execution role has permissions to access DynamoDB (at least dynamodb:PutItem and dynamodb:Scan on your table).

Usage

Invoke the Lambda function by sending an event with a command field. The command can be any string, but if print_db is sent, the function will scan the DynamoDB table and return its contents.

Example Event

{
  "command": "example_command"
}

Special Command

To print the contents of the DynamoDB table, use:

{
  "command": "print_db"
}

Development

Local Setup

Ensure you have Rust and Cargo installed. Clone the repository and navigate into the project directory. Then use cargo lambda to deploy and invoke.

rust-lambda-x-db's People

Contributors

sanjeev-one avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.