diff --git a/.gitignore b/.gitignore index f29279b..9e94c20 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ Gemfile.lock .test-runner/ .vscode/ -.scratch \ No newline at end of file +.scratch +.idea \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index a98e134..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 828d50f..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Dockerfile.rie b/Dockerfile.rie index 021150f..671b9b8 100644 --- a/Dockerfile.rie +++ b/Dockerfile.rie @@ -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}/ diff --git a/README.md b/README.md index d523104..be3c4cb 100644 --- a/README.md +++ b/README.md @@ -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