Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ Gemfile.lock
.test-runner/

.vscode/
.scratch
.scratch
.idea
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile.rie
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM public.ecr.aws/lambda/ruby:3.3
FROM public.ecr.aws/lambda/ruby:3.4

# Copy source code and build gem in container
COPY . ${LAMBDA_TASK_ROOT}/
Expand Down
87 changes: 26 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,84 +25,49 @@ If you're upgrading from 2.x, update your Dockerfile to use the `_HANDLER` envir

## Usage

### Creating a Docker Image for Lambda with the Runtime Interface Client
First step is to choose the base image to be used. The supported Linux OS distributions are:

- Amazon Linux 2023
- Amazon Linux 2
- Alpine
- Debian
- Ubuntu

In order to install the Runtime Interface Client, either add this line to your application's Gemfile:
Create a Ruby handler. This is an example `app.rb`:

```ruby
gem 'aws_lambda_ric'
module App
class Handler
def self.process(event:, context:)
"Hello World!"
end
end
end
```

And then execute:
### Creating a Docker Image for Lambda with the Runtime Interface Client

#### Supported Base Operating Systems

$ bundle
The Ruby Runtime Interface Client supports the following Linux distributions:

Or install it manually as:
- **Amazon Linux 2023**
- **Alpine**
- **Debian**
- **Ubuntu**

$ gem install aws_lambda_ric
For Alpine, Debian, and Ubuntu, we support the latest LTS release and the previous LTS release for 6 months after a new LTS version has been released.
First step is to choose the base image to be used.

The next step would be to copy your Lambda function code into the image's working directory.
You will need to set the `ENTRYPOINT` property of the Docker image to invoke the Runtime Interface Client and
set the `_HANDLER` environment variable to specify the desired handler.
#### Amazon Linux 2023

**Important**: The Runtime Interface Client requires the handler to be specified via the `_HANDLER` environment variable.
AWS Lambda provides ready to use OCI image based on Amazon Linux 2023, you just need to copy your handler file and specify the `CMD` command.

Example Dockerfile:
```dockerfile
FROM amazonlinux:latest

# Define custom function directory
ARG FUNCTION_DIR="/function"

# Install ruby
RUN dnf install -y ruby3.2 make

# Install bundler
RUN gem install bundler

# Install the Runtime Interface Client
RUN gem install aws_lambda_ric
FROM public.ecr.aws/lambda/ruby:3.4

# Copy function code
RUN mkdir -p ${FUNCTION_DIR}
COPY app.rb ${FUNCTION_DIR}
# Add your handler definition
ADD test/integration/test-handlers/echo/app.rb .

WORKDIR ${FUNCTION_DIR}

# Set the handler via environment variable
ENV _HANDLER="app.App::Handler.process"

ENTRYPOINT ["/usr/local/bin/aws_lambda_ric"]
```

Note that the `ENTRYPOINT` may differ based on the base image used. You can find the correct path by running an
interactive shell in the container and checking the installed location of the gem.

```shell script
docker run -it --rm amazonlinux:latest bash
yum install -y which ruby
gem install aws_lambda_ric
which aws_lambda_ric
# Specify your handler
CMD ["app.App::Handler.process"]
```

Finally, create a Ruby handler. This is an example `app.rb`:
For other distributions, please refer to Dockerfiles in the [test/integration/docker](test/integration/docker) directory.

```ruby
module App
class Handler
def self.process(event:, context:)
"Hello World!"
end
end
end
```

### Local Testing

Expand Down
Loading