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:
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.
You'll want to be able to test and write Ruby code outside of Docker, too.
gem install bundler
Check it with:
ruby -v
# ruby 3.2.x
bundle -v
# Bundler version 2.x
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.
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:
Once these steps are done, feel free to jump right into the rest of Chapter 3.