Giter Site home page Giter Site logo

asaaki / rust-wasm-on-lambda-edge Goto Github PK

View Code? Open in Web Editor NEW
26.0 4.0 1.0 1.5 MB

Rust/WASM on AWS Lambda@Edge (CloudFront)

Home Page: https://markentier.tech/posts/2021/01/rust-wasm-on-aws-lambda-edge/

License: Apache License 2.0

Makefile 18.63% JavaScript 4.91% TypeScript 4.21% Rust 72.25%
rust rust-lang wasm wasm-bindgen wasm-pack aws aws-lambda aws-lambda-edge aws-cloudfront nodejs cloudfront

rust-wasm-on-lambda-edge's Introduction

Rust/Wasm on AWS Lambda@Edge (CloudFront)

Read the accompanying blog post to this project.

Since we still cannot have native Rust (or WebAssembly for that matter) on AWS Lambda@Edge, we have to come up with our own solution. Here I present mine: using the AWS Lambda Node.js enviroment to execute our Wasm blob generated from Rust code.

tl;dr

make build
make call
make zip
# upload to your AWS Lambda and attach it to a CloudFront distribution (as viewer request trigger)
# check the Cloudwatch logs in the regions you made requests
# be happy - Have a nice day!

This demo doesn't do anything fancy. In fact, it does not alter the request at all and only passes it through as-is.

The function will make a few log statements, check the Cloudwatch logs in the regions you received requests for your CloudFront distribution.

This setup is good to test for the baseline performance.

After the cold-start some requests later the function duration should be around 1 to 2 ms.

Depending on the region and where you are, this translates to 40 to 50 ms in request latency for a small static asset, while without any trigger attached the same request would take around 25 ms.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

rust-wasm-on-lambda-edge's People

Contributors

asaaki avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rust-wasm-on-lambda-edge's Issues

run code error with "dynamically require"

Bug Report

I mostly worked on Rust and recently need to deploy some of our services written in Rust to AWS Lambda@Edge and this is a great example to start with, thanks

the test code running well both in local and AWS cloudfront. I use this as the framework and link our code as crates, and then I have the following error when run "make call" I don't really known how to solve it (I've searched the rollup document but still don't get how to solve this, since I don't use rollup before).

do you know what it might issue with this, thanks a lot!

Error: Could not dynamically require "./snippets/app_edge-d7b4f29aba445e31/inline0.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.
    at _ (/opt/work/app_edge/request/build.function/index.js:1:241)
    at /opt/work/app_edge/request/build.function/index.js:1:5422
    at Object.<anonymous> (/opt/work/app_edge/request/build.function/index.js:1:16865)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/opt/work/app_edge/request/fixtures/viewer-request-call-test.js:1:23)
make: *** [Makefile:58: call] Error 1

Current Behavior

Code/Gist

Expected behavior/code

Environment

Rust: 1.59.0
OS: ubuntu:20.04

Possible Solution

Additional context/screenshots

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.