All Projects → iliana → Rust Crowbar

iliana / Rust Crowbar

Licence: other
Wrapper to simplify writing AWS Lambda functions in Rust (using the Python execution environment)

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Rust Crowbar

Components
The Serverless Framework's new infrastructure provisioning technology — Build, compose, & deploy serverless apps in seconds...
Stars: ✭ 2,259 (+1040.91%)
Mutual labels:  aws, serverless, aws-lambda
Archive aws Lambda Go Net
Network I/O interface for AWS Lambda Go runtime.
Stars: ✭ 151 (-23.74%)
Mutual labels:  aws, serverless, aws-lambda
Serverless Sam
Serverless framework plugin to export AWS SAM templates for a service
Stars: ✭ 143 (-27.78%)
Mutual labels:  aws, serverless, aws-lambda
Middy
🛵 The stylish Node.js middleware engine for AWS Lambda
Stars: ✭ 2,592 (+1209.09%)
Mutual labels:  aws, serverless, aws-lambda
Aws Cdk Changelogs Demo
This is a demo application that uses modern serverless architecture to crawl changelogs from open source projects, parse them, and provide an API and website for viewing them.
Stars: ✭ 197 (-0.51%)
Mutual labels:  aws, serverless, aws-lambda
Serverless Pg
A package for managing PostgreSQL connections at SERVERLESS scale
Stars: ✭ 142 (-28.28%)
Mutual labels:  aws, serverless, aws-lambda
Serverless Sentry Plugin
This plugin adds automatic forwarding of errors and exceptions to Sentry (https://sentry.io) and Serverless (https://serverless.com)
Stars: ✭ 146 (-26.26%)
Mutual labels:  aws, serverless, aws-lambda
Aws Lambda List
A list of hopefully useful AWS lambdas and lambda-related resources.
Stars: ✭ 130 (-34.34%)
Mutual labels:  aws, serverless, aws-lambda
Terraform Aws Lambda
Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations
Stars: ✭ 190 (-4.04%)
Mutual labels:  aws, serverless, aws-lambda
Cartoonify
Deploy and scale serverless machine learning app - in 4 steps.
Stars: ✭ 157 (-20.71%)
Mutual labels:  aws, serverless, aws-lambda
Shadowreader
Serverless load testing for replaying website traffic. Powered by AWS Lambda.
Stars: ✭ 138 (-30.3%)
Mutual labels:  aws, serverless, aws-lambda
Serverlessish
Run the same Docker images in AWS Lambda and AWS ECS
Stars: ✭ 177 (-10.61%)
Mutual labels:  aws, serverless, aws-lambda
Spark On Lambda
Apache Spark on AWS Lambda
Stars: ✭ 137 (-30.81%)
Mutual labels:  aws, serverless, aws-lambda
Chrome Aws Lambda
Chromium Binary for AWS Lambda and Google Cloud Functions
Stars: ✭ 2,502 (+1163.64%)
Mutual labels:  aws, serverless, aws-lambda
Cra Serverless
Serverless pre-rendering (SSR) for React SPA using AWS Lambda, S3, and CloudFront.
Stars: ✭ 137 (-30.81%)
Mutual labels:  aws, serverless, aws-lambda
Selfie2anime
Anime2Selfie Backend Services - Lambda, Queue, API Gateway and traffic processing
Stars: ✭ 146 (-26.26%)
Mutual labels:  aws, serverless, aws-lambda
Iopipe Js Core
Observe and develop serverless apps with confidence on AWS Lambda with Tracing, Metrics, Profiling, Monitoring, and more.
Stars: ✭ 123 (-37.88%)
Mutual labels:  aws, serverless, aws-lambda
Architect
The simplest, most powerful way to build serverless applications
Stars: ✭ 1,925 (+872.22%)
Mutual labels:  aws, serverless, aws-lambda
Serverless Next.js
⚡ Deploy your Next.js apps on AWS Lambda@Edge via Serverless Components
Stars: ✭ 2,977 (+1403.54%)
Mutual labels:  aws, serverless, aws-lambda
Serverless Aws Alias
Alias support for Serverless 1.x
Stars: ✭ 171 (-13.64%)
Mutual labels:  aws, serverless, aws-lambda

rust-crowbar

Build Status crates.io docs.rs

logo

crowbar makes it easy to write AWS Lambda functions in Rust. It wraps native Rust functions into CPython modules that handle converting Python objects into Rust objects and back again.

Usage

Add both crowbar and cpython to your Cargo.toml:

[dependencies]
crowbar = "0.3"
cpython = "0.2"

Use macros from both crates:

#[macro_use(lambda)]
extern crate crowbar;
#[macro_use]
extern crate cpython;

And write your function using the lambda! macro:

lambda!(|event, context| {
    println!("hi cloudwatch logs, this is {}", context.function_name());
    // return the event without doing anything with it
    Ok(event)
});

Building Lambda Functions

For your code to be usable in AWS Lambda's Python execution environment, you need to compile to a dynamic library with the necessary functions for CPython to run. The lambda! macro does most of this for you, but Cargo still needs to know what to do.

You can configure Cargo to build a dynamic library with the following. If you're using the lambda! macro as above, you need to use lambda for the library name (see the documentation for lambda! if you want to use something else).

[lib]
name = "lambda"
crate-type = ["cdylib"]

cargo build will now build a liblambda.so. Put this in a zip file and upload it to an AWS Lambda function. Use the Python 3.6 execution environment with the handler configured as liblambda.handler.

Build Environment

It is notoriously difficult to build a properly-linked shared library against the Lambda execution environment. Using either an Amazon Linux AMI or the Amazon Linux Docker image, even if using the exact version as Lambda, any package installations will likely upgrade OpenSSL from 1.0.1k to 1.0.2k, causing a linker exception at runtime. @naftulikay lost a ridiculous amount of time trying to statically compile, pin package versions, and try linker hacks.

The best solution available is to use the lambci/lambda:build-python3.6 Docker image which is built from an exact filesystem replica via tarballing the filesystem at runtime from a Python 3.6 runtime Lambda function. The authors went to extensive lengths to pin packages and replicate the environment as accurately as possible, and experience has shown this is the best way to build Python 3.6 shared libraries.

@naftulikay created a sample Rust build environment based on the upstream lambci/lambda:build-python3.6 image at naftulikay/crowbar. Previously, naftulikay/circleci-amazonlinux-rust was used and the aforementioned issues were encountered. Despite CircleCI being used in the name, the image is a fairly generic Rust build environment and should be fairly portable and resuable. For Travis CI and CircleCI examples, please look in the examples/ci directory.

Because you're building a dynamic library, other libraries that you're dynamically linking against need to also be in the Lambda execution environment. By using the lambci/lambda:build-python3.6 image, the build environment will be consistent with the runtime environment.

As described here, the Lambda execution environment uses a runtime library path equivalent to:

LD_LIBRARY_PATH=/lib64:/usr/lib64:$LAMBDA_TASK_ROOT:$LAMBDA_TASK_ROOT/lib

@naftulikay wrote a fairly naïve Python script which will recursively copy linked libraries into the deployment package under lib/. This ensures that any non-standard libraries will be available on the library path at runtime. See the examples/ci/{travis,circle} directories for examples on how to use this, and see naftulikay/docker-crowbar for more information.

Deployment

Serverless framework

Serverless framework is an extemely popular workflow tool for developing and deploying serverless applications and comes with in depth guides for AWS lambda. Serverless framework is surrounded by a strong ecosystem of plugins including a plugin for deploying Rust applications. A serverless rust template for quickly bootstraping, building, and deploying crowbar applications can be found here.

Contributing

crowbar welcomes your contributions:

  • Let us know if you use crowbar in production
  • If you have a bug report or an idea, submit an issue
  • If you want something to work on, check the issues list
  • Please submit non-trivial changes as an issue first; send a pull request when the implementation is agreed on

crowbar follows a code of conduct; please read it.

Alternatives

As AWS Lambda has added more runtimes, more ways to run Rust on Lambda have emerged.

The Rust on AWS Lambda project is kind enough to offer an alternative, and a comparison of itself to crowbar.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].