SERVERLESS RUBY
Build and Deploy AWS Lambda Functions from Scratch

Interlude: Getting Your Machine Ready

Before You Begin: Setup Checklist

Before we dive into building Lambda functions, make sure your local environment is ready to run Dockerized Ruby code.

You'll need the following tools installed:


๐Ÿณ 1. Docker

Docker lets you run containers locally, which is how we'll package and test your Lambda functions.

docker --version
# Example output: Docker version 24.0.2, build cb74dfc

If that works, you're good.


๐Ÿงฐ 2. Ruby + Bundler (Locally)

You'll want to be able to test and write Ruby code outside of Docker, too.

  • Install Ruby (preferably 3.x)
    • If you're on macOS and use Homebrew:
      brew install ruby
    • Or use a Ruby version manager like rbenv or asdf
  • Then install Bundler:
    gem install bundler

Check it with:

ruby -v
# ruby 3.2.x

bundle -v
# Bundler version 2.x

๐Ÿงช 3. Optional: Docker Compose (For Local Dev)

Docker Compose lets you run multiple containers or test environments with one file.

Most Docker Desktop installations already include docker-compose. Check with:

docker-compose --version
# or
docker compose version

If you see a version number, you're set.


๐Ÿ—‚ 4. Directory Setup

Create a directory for your Lambda function. For example:

mkdir my_lambda_function
cd my_lambda_function

You'll be copying files like function.rb, Dockerfile, and Gemfile into this directory.


With this setup, you'll be able to:

  • Build your Docker image
  • Run it locally
  • Push it to AWS later

Once these steps are done, feel free to jump right into the rest of Chapter 3.