I heard a lot of great things about Rust.  The promise of a C-like language with guaranteed memory safety sounds too good to pass up.  It's super fast, and seemed to be a useful language to learn given you can write code for embedded systems, command line applications, and front-end and back-end web applications.

What's Rust?

On their website, Rust states their intentions are to create a language that empowers everyone to build reliable and efficient software.  It's major features include memory and thread safety, which is a common area for bugs to show up in code.  Rust is created and supported by Mozilla and can be found here: https://www.rust-lang.org/.  Another helpful resource is their thorough tutorial they affectionately call "The Book": https://doc.rust-lang.org/stable/book/title-page.html.

Rust on AWS Lambda

All that being said, why not set up an AWS Lambda to run my Rust code!  Rust isn't a supported runtime for AWS Lambda, so this will also be good experience working with provided runtimes.

Luckily, AWS Labs has done a lot of the leg work getting Rust to run on Lambda.  Check out the links below for more information.  Be wary, as the current "release" of the rust lambda framework at the time of writing this is out of date.  I recommend trying the example laid out in the GitHub issue at the end of the list.  A working is sample is also available in my source code at the end of this article.

Making an HTTPS request

A major hurdle with running bytecode on another platform than the development machine is cross-compilation.  At the time of writing this, many of the major HTTPS request libraries for Rust rely on OpenSSL.  The OpenSSL library needs to be compiled for the target platform in order for the dependent HTTPS library to work correctly.  I gave it a couple tries, but working with C isn't my area of expertise.  I instead found that I could use rustls using hyper-rustls without a lot of hassle.  

Source Code

My source code is below!  Feel free to use it as a template for your own needs.  Hopefully it helps.  Since I'm new to Rust, any feedback is appreciated.

mitchgollub/rust-lambda-https
Contribute to mitchgollub/rust-lambda-https development by creating an account on GitHub.