Skip to content
Runs your actix-web app as a lambda app that will respond to Application Load Balancer requests
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
helpers Redo targetgroup/listener in cloudformation Apr 22, 2019
src Ignore lambda main that would break under doctest Apr 20, 2019
.gitignore Files from dawn Apr 20, 2019
.travis.yml Only document the main package Apr 20, 2019
Cargo.lock Add readme/categories data Apr 20, 2019
Cargo.toml Add readme/categories data Apr 20, 2019
README.md Add crates badge Apr 20, 2019
rustfmt.toml Files from dawn Apr 20, 2019

README.md

actix_lambda

Build Status Crates.io

Helper libraries for running/testing Actix servers under AWS Lambda

Currently, it just consists of a simple helper function run that will run the entire app as a lambda function, and lambda_test which will feed in a single Application Load Balancer event into the Lambda app.

Usage

fn app() -> App {
    return App::new()
        .route("/", Method::GET, root_handler);
        // More route handlers
}

fn main() {
    actix_lambda::run(app);
}

#[cfg(test)]
mod tests {
    #[test]
    fn lambda_test() {
        actix_lambda::test::lambda_test(main);
    }
}

In addition to the Rust code, there's also some Python work with CloudFormation and Troposphere to enable building stacks with this. To deploy this do the following:

  1. Have a CLI-configured AWS account
  2. rustup target add x86_64-unknown-linux-musl
  3. brew install filosottile/musl-cross/musl-cross (or do Linux-equivalent steps to get a Musl cross-compiler)
  4. mkdir .cargo && echo '[target.x86_64-unknown-linux-musl]\nlinker = "x86_64-linux-musl-gcc"' > .cargo/config
  5. cargo build --release --target x86_64-unknown-linux-musl
  6. cd <copy of the helpers directory from here>
  7. pip install -r requirements.txt
  8. python cf.py <path to your app's root>
    • This will make a CloudFormation stack named after your app, and then do some custom configuration of the TargetGroup and Listener for the ALB to workaround an upstream bug

You should now be able to run your app from the URL that the script spat out.

TODO

You can’t perform that action at this time.