Skip to main content

Welcome Lamby v4!

· 4 min read
Ken Collins

I am incredibly happy to announcy Lamby v4 and a major update to our documentation website. Huge shout out to Docusaurus which has made in my opinion the best content-driven static site generator for open-source projects like our Lamby community.

Lamby: Simple Rails & AWS Lambda Integration using RackLamby: Simple Rails & AWS Lambda Integration using Rack

So what is new and will v4 break anything? Lots! Mostly new ways of thinking around the same basic architecture. Nothing should break either. Lamby v4's semver change is mostly marketing driven. Here is a short list of what is new.

Updated Starter

Want to see all this new stuff in action? Use our Quick Start guide to deploy a new Rails application to AWS Lambda in 5min ⏱️.

Bring Your Own Containers

Lamby still works with the Zip packaging format, but all documentation on how to use it has been removed. Containers are here to stay and their value goes way past a simple packaging format.

We now encourage bringing your own containers by using Lambda's Runtime Interface Client (RIC). The RIC allows us to use Docker's CMD to load Rails and invoke a function. In this case we are loading our Rails application through its config/environment.rb file (.rb extension is implied) and once that is done, calling the new Lamby.cmd as the Lambda handler. No more app.rb file needed!

Dockerfile
FROM ruby:3.2-bullseye
RUN gem install 'aws_lambda_ric'
ENTRYPOINT [ "/usr/local/bundle/bin/aws_lambda_ric" ]
CMD ["config/environment.Lamby.cmd"]

Secrets with Crypteia

The Crypteia package is Rust Lambda Extension for any Runtime/Container to preload SSM Parameters as secure environment variables. It takes advantages of LD_PRELOAD to seamlessly fetch values from SSM when a process starts and then injects them as natively accesible Ruby ENV variables. Our Quick Start guide's cookiecutter includes Crypteia already for you via a Docker COPY command into the Lambda Extension /opt directory.

Dockerfile
FROM ruby:3.2-bullseye
COPY --from=ghcr.io/rails-lambda/crypteia-extension-debian:1 /opt /opt

Usage is simply done by adding variables to your SAM template and accessing the values fetched from SSM like any other environment variable. Please read the Crypteia's documentation for full details.

Globals:
Environment:
Variables:
SECRET: x-crypteia-ssm:/myapp/SECRET
ENV['SECRET'] # 1A2B3C4D5E6F

Development Containers

Described in the Quick Start guide, our Lamby starter makes use of the Development Container specification via a .devcontainer directory. Commonly used with Codespaces, dev containers can be used locally with any editor.

Our dev container's Dockerfile uses the same base image as the one at the root of your project. This helps ensure your development experience, like installing system dependencies and Ruby gems with native extensions, aligns with the same process as your production image.

We also leverage the devcontainer's dockerComposeFile capability to include a MySQL service as well. The Lamby starter also includes a range of devcontainer features which are installed within the Ubuntu development image. For example, Node, Docker in Docker, SSH, and the AWS CLI & SAM CLI.