aws_lambda_ric 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7531514e0f2ab9ba840cdcd973a36cadb45e9887db24a7fa0337e6eaca16e8a
4
- data.tar.gz: b1be16c96fdc08b4651e99a4eb20f17ca3af69dee48476e58b075b910863a72d
3
+ metadata.gz: 0f2523ec3d2acb227fa11e42ec19db8e6cfed477fd3fe696437e15ad403290c9
4
+ data.tar.gz: ada075ea78b2b5004ba1afae30a176621a7fb721d897911450916cd0605c02ad
5
5
  SHA512:
6
- metadata.gz: 7a9d932188a665f2865a71c9e7d06a6864fd7728925589e587c3ef71926c20ae0345cb9b7879c7457f586f7956df3ec41260038464ef34d50af6a785c81cfd71
7
- data.tar.gz: 2b00da39020716fda73d50954e74ec76013a2aa0548c363411d743c03e01b888ff59a123921cf8915bef617cae0ebde7a35743588a589ca56edb5649fb88a956
6
+ metadata.gz: a30b399adaafe4a614e8cbe4ebfebbec435fbeafe9be10e87033e6555a3b9dccb6ccaa2ac1d2a4ee1f909a067b9a1bf350317bb6e397786ee39ce44fa543926c
7
+ data.tar.gz: 9e2deffd3a8ad44bb62a5d9b66a8c3cf8b01ca70e3dd2a4898be35946cc69bef334e4e172d10d163c94194b54277fe7a2b7c0644364250848b6d83d6e09c7a92
data/README.md CHANGED
@@ -1,22 +1,23 @@
1
1
  ## AWS Lambda Ruby Runtime Interface Client
2
2
 
3
- We have open-sourced a set of software packages, Runtime Interface Clients (RIC), that implement the Lambda
4
- [Runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html), allowing you to seamlessly extend your preferred
5
- base images to be Lambda compatible.
6
- The Lambda Runtime Interface Client is a lightweight interface that allows your runtime to receive requests from and send requests to the Lambda service.
3
+ We have open-sourced a set of software packages, Runtime Interface Clients (RIC), that implements the Lambda
4
+ [Runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html), allowing you to seamlessly extend
5
+ your preferred base images to be Lambda compatible.
6
+ The Lambda Runtime Interface Client is a lightweight interface that allows your runtime to
7
+ receive requests from and send requests to the Lambda service.
7
8
 
8
9
  The Lambda Ruby Runtime Interface Client is vended through [rubygems](https://rubygems.org/gems/aws_lambda_ric).
9
10
  You can include this package in your preferred base image to make that base image Lambda compatible.
10
11
 
11
12
  ## Requirements
12
- The Ruby Runtime Interface Client package currently supports Ruby versions:
13
- - 2.5.x up to and including 2.7.x
13
+ The Ruby Runtime Interface Client package currently supports ruby 3.0 and above.
14
14
 
15
15
  ## Usage
16
16
 
17
17
  ### Creating a Docker Image for Lambda with the Runtime Interface Client
18
18
  First step is to choose the base image to be used. The supported Linux OS distributions are:
19
19
 
20
+ - Amazon Linux 2023
20
21
  - Amazon Linux 2
21
22
  - Alpine
22
23
  - Debian
@@ -36,17 +37,9 @@ Or install it manually as:
36
37
 
37
38
  $ gem install aws_lambda_ric
38
39
 
39
-
40
- Next step would be to copy your Lambda function code into the image's working directory.
41
- ```dockerfile
42
- # Copy function code
43
- RUN mkdir -p ${FUNCTION_DIR}
44
- COPY app.rb ${FUNCTION_DIR}
45
-
46
- WORKDIR ${FUNCTION_DIR}
47
- ```
48
-
49
- The next step would be to set the `ENTRYPOINT` property of the Docker image to invoke the Runtime Interface Client and then set the `CMD` argument to specify the desired handler.
40
+ The next step would be to copy your Lambda function code into the image's working directory.
41
+ You will need to set the `ENTRYPOINT` property of the Docker image to invoke the Runtime Interface Client and
42
+ then set the `CMD` argument to specify the desired handler.
50
43
 
51
44
  Example Dockerfile:
52
45
  ```dockerfile
@@ -56,7 +49,7 @@ FROM amazonlinux:latest
56
49
  ARG FUNCTION_DIR="/function"
57
50
 
58
51
  # Install ruby
59
- RUN amazon-linux-extras install -y ruby2.6
52
+ RUN dnf install -y ruby3.2 make
60
53
 
61
54
  # Install bundler
62
55
  RUN gem install bundler
@@ -64,6 +57,15 @@ RUN gem install bundler
64
57
  # Install the Runtime Interface Client
65
58
  RUN gem install aws_lambda_ric
66
59
 
60
+ # If you want to install Runtime Interface Client From Source, you can uncomment the following `ADD` and `RUN` layers.
61
+ # Do not forget to comment/remove the above `RUN gem install aws_lambda_ric` command.
62
+ # ADD https://github.com/aws/aws-lambda-ruby-runtime-interface-client.git /aws_lambda_ric
63
+ # RUN cd /aws_lambda_ric && \
64
+ # make init && \
65
+ # make build && \
66
+ # gem install --local /aws_lambda_ric/pkg/aws_lambda_ric-3.0.0.gem && \
67
+ # rm -rf /aws_lambda_ric
68
+
67
69
  # Copy function code
68
70
  RUN mkdir -p ${FUNCTION_DIR}
69
71
  COPY app.rb ${FUNCTION_DIR}
@@ -74,7 +76,18 @@ ENTRYPOINT ["/usr/local/bin/aws_lambda_ric"]
74
76
  CMD ["app.App::Handler.process"]
75
77
  ```
76
78
 
77
- Example Ruby handler `app.rb`:
79
+ Note that the `ENTRYPOINT` may differ based on the base image used. You can find the correct path by running an
80
+ interactive shell in the container and checking the installed location of the gem.
81
+
82
+ ```shell script
83
+ docker run -it --rm amazonlinux:latest bash
84
+ yum install -y which ruby
85
+ gem install aws_lambda_ric
86
+ which aws_lambda_ric
87
+ ```
88
+
89
+ Finally, create a Ruby handler. This is an example `app.rb`:
90
+
78
91
  ```ruby
79
92
  module App
80
93
  class Handler
@@ -87,7 +100,10 @@ end
87
100
 
88
101
  ### Local Testing
89
102
 
90
- To make it easy to locally test Lambda functions packaged as container images we open-sourced a lightweight web-server, Lambda Runtime Interface Emulator (RIE), which allows your function packaged as a container image to accept HTTP requests. You can install the [AWS Lambda Runtime Interface Emulator](https://github.com/aws/aws-lambda-runtime-interface-emulator) on your local machine to test your function. Then when you run the image function, you set the entrypoint to be the emulator.
103
+ To make it easy to locally test Lambda functions packaged as container images we open-sourced a lightweight web-server,
104
+ Lambda Runtime Interface Emulator (RIE), which allows your function packaged as a container image to accept HTTP requests.
105
+ You can install the [AWS Lambda Runtime Interface Emulator](https://github.com/aws/aws-lambda-runtime-interface-emulator) on your local machine to test your function.
106
+ Thenm when you run the image function, you set the entrypoint to be the emulator.
91
107
 
92
108
  *To install the emulator and test your Lambda function*
93
109
 
@@ -98,7 +114,8 @@ mkdir -p ~/.aws-lambda-rie && \
98
114
  curl -Lo ~/.aws-lambda-rie/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie && \
99
115
  chmod +x ~/.aws-lambda-rie/aws-lambda-rie
100
116
  ```
101
- 2) Run your Lambda image function using the docker run command.
117
+
118
+ 1) Run your Lambda image function using the docker run command.
102
119
 
103
120
  ```shell script
104
121
  docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 \
@@ -109,7 +126,7 @@ docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 \
109
126
 
110
127
  This runs the image as a container and starts up an endpoint locally at `http://localhost:9000/2015-03-31/functions/function/invocations`.
111
128
 
112
- 3) Post an event to the following endpoint using a curl command:
129
+ 1) Post an event to the following endpoint using a curl command:
113
130
 
114
131
  ```shell script
115
132
  curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
@@ -3,7 +3,7 @@
3
3
  class LambdaContext
4
4
  attr_reader :aws_request_id, :invoked_function_arn, :log_group_name,
5
5
  :log_stream_name, :function_name, :memory_limit_in_mb, :function_version,
6
- :identity, :client_context, :deadline_ms
6
+ :identity, :tenant_id, :client_context, :deadline_ms
7
7
 
8
8
  def initialize(request)
9
9
  @clock_diff = Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond) - Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
@@ -16,6 +16,7 @@ class LambdaContext
16
16
  @memory_limit_in_mb = ENV['AWS_LAMBDA_FUNCTION_MEMORY_SIZE']
17
17
  @function_version = ENV['AWS_LAMBDA_FUNCTION_VERSION']
18
18
  @identity = JSON.parse(request['Lambda-Runtime-Cognito-Identity']) unless request['Lambda-Runtime-Cognito-Identity'].to_s.empty?
19
+ @tenant_id = request['Lambda-Runtime-Aws-Tenant-Id'] unless request['Lambda-Runtime-Aws-Tenant-Id'].to_s.empty?
19
20
  @client_context = JSON.parse(request['Lambda-Runtime-Client-Context']) unless request['Lambda-Runtime-Client-Context'].to_s.empty?
20
21
  end
21
22
 
@@ -4,19 +4,15 @@ module LoggerPatch
4
4
  def initialize(logdev, shift_age = 0, shift_size = 1048576, level: 'debug',
5
5
  progname: nil, formatter: nil, datetime_format: nil,
6
6
  binmode: false, shift_period_suffix: '%Y%m%d')
7
- # use unpatched constructor if logdev is a filename or an IO Object other than $stdout or $stderr
8
- if logdev && logdev != $stdout && logdev != $stderr
9
- super(logdev, shift_age, shift_size, level: level, progname: progname,
10
- formatter: formatter, datetime_format: datetime_format,
11
- binmode: binmode, shift_period_suffix: shift_period_suffix)
12
- else
13
- self.level = level
14
- self.progname = progname
7
+ logdev_lambda_overwrite = logdev
8
+ # use unpatched constructor if logdev is a filename or an IO Object other than $stdout or $stderr
9
+ if !logdev || logdev == $stdout || logdev == $stderr
10
+ logdev_lambda_overwrite = AwsLambdaRIC::TelemetryLogger.telemetry_log_sink
15
11
  @default_formatter = LogFormatter.new
16
- self.datetime_format = datetime_format
17
- self.formatter = formatter
18
- @logdev = AwsLambdaRIC::TelemetryLogger.telemetry_log_sink
19
- @level_override = {}
20
12
  end
13
+
14
+ super(logdev_lambda_overwrite, shift_age, shift_size, level: level, progname: progname,
15
+ formatter: formatter, datetime_format: datetime_format,
16
+ binmode: binmode, shift_period_suffix: shift_period_suffix)
21
17
  end
22
18
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AwsLambdaRIC
4
- VERSION = '3.0.0'
4
+ VERSION = '3.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_lambda_ric
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AWS Lambda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-19 00:00:00.000000000 Z
11
+ date: 2025-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler