You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: CONTRIBUTING.md
+2-3
Original file line number
Diff line number
Diff line change
@@ -19,11 +19,10 @@ reported the issue. Please try to include as much information as you can. Detail
19
19
* Any modifications you've made relevant to the bug
20
20
* Anything unusual about your environment or deployment
21
21
22
-
IMPORTANT: Everything under `/lambda` is a mirrored version of AWS Lambda's Runtime API. Due to this, we are not accepting
23
-
contributions to any code within this directory.
24
-
25
22
26
23
## Contributing via Pull Requests
24
+
This repository contains the source code and examples for the Runtime Interface Emulator. We will accept pull requests on documentation, examples, bug fixes and the Dockerfiles. We will also accept pull requests, issues and feedback on improvements to the Runtime Interface Emulator. However, our priority will be to maintain fidelity with AWS Lambda’s Runtime Interface on the cloud.
25
+
27
26
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
28
27
29
28
1. You are working against the latest source on the *main* branch.
AWS Lambda Runtime Interface Emulator emulates the AWS Lambda Runtime API. This can be used to run your Lambda Functions
6
-
locally through a container tooling, such as Docker. When `aws-lambda-rie` is executed, a
7
-
/2015-03-31/functions/function/invocations endpoint will be stood up within the container that you post data to it in
8
-
order to invoke your function for testing.
5
+
The Lambda Runtime Interface Emulator is a proxy for Lambda’s Runtime and Extensions APIs, which allows customers to
6
+
locally test their Lambda function packaged as a container image. It is a lightweight web-server that converts
7
+
HTTP requests to JSON events and maintains functional parity with the Lambda Runtime API in the cloud. It
8
+
allows you to locally test your functions using familiar tools such as cURL and the Docker CLI (when testing
9
+
functions packaged as container images). It also simplifies running your application on additional computes.
10
+
You can include the Lambda Runtime Interface Emulator in your container image to have it accept HTTP
11
+
requests instead of the JSON events required for deployment to Lambda. This component does not emulate
12
+
Lambda’s orchestrator, or security and authentication configurations. You can get started by downloading and installing it on your local machine. When the Lambda Runtime API emulator is executed, a `/2015-03-31/functions/function/invocations` endpoint will be stood up within the container that you post data to it in order to invoke your function for testing.
9
13
10
-
Installing
14
+
15
+
## Installing
11
16
12
17
Instructions for installing AWS Lambda Runtime Interface Emulator for your platform
13
18
@@ -18,42 +23,110 @@ Instructions for installing AWS Lambda Runtime Interface Emulator for your platf
18
23
| Windows |`Invoke-WebRequest -OutFile 'C:\Program Files\aws lambda\aws-lambda-rie' https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie`|
19
24
20
25
21
-
Getting started
26
+
## Getting started
27
+
28
+
There are a few ways you use the Runtime Interface Emulator (RIE) to locally test your function depending on the base image used.
29
+
30
+
31
+
### Test an image with RIE included in the image
32
+
33
+
The AWS base images for Lambda include the runtime interface emulator. You can also follow these steps if you built the RIE into your alternative base image.
34
+
35
+
#### To test your Lambda function with the emulator
36
+
37
+
1. Build your image locally using the docker build command.
38
+
39
+
`docker build -t myfunction:latest .`
40
+
41
+
2. Run your container image locally using the docker run command.
42
+
43
+
`docker run -p 9000:8080 myfunction:latest`
44
+
45
+
This command runs the image as a container and starts up an endpoint locally at `localhost:9000/2015-03-31/functions/function/invocations`.
46
+
47
+
3. Post an event to the following endpoint using a curl command:
1. Create a script and save it in your project directory. The following example shows a typical script for a Node.js function. The presence of the AWS_LAMBDA_RUNTIME_API environment variable indicates the presence of the runtime API. If the runtime API is present, the script runs the runtime interface client (https://docs.aws.amazon.com/lambda/latest/dg/runtimes-images.html#runtimes-api-client). Otherwise, the script runs the runtime interface emulator.
35
60
36
-
How to configure
61
+
*`#!/bin/sh if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then exec /usr/local/bin/aws-lambda-rie /usr/bin/npx aws-lambda-ricelseexec /usr/bin/npx aws-lambda-ricfi`
62
+
* Download the runtime interface emulator (https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie) from GitHub into your project directory.
63
+
* Install the emulator package and change ENTRYPOINT to run the new script by adding the following lines to your Dockerfile:
64
+
```
65
+
ADD aws-lambda-rie /usr/local/bin/aws-lambda-rie
66
+
ENTRYPOINT [ “/entry_script.sh” ]
67
+
```
68
+
69
+
2. Build your image locally using the docker build command.
70
+
71
+
`docker build -t myfunction:latest .`
72
+
`docker run -p 9000:8080 myfunction:latest`
73
+
74
+
### Test an image without adding RIE to the image
75
+
76
+
You install the runtime interface emulator to your local machine. When you run the image function, you set the entry point to be the emulator.
77
+
*To test an image without adding RIE to the image *
78
+
79
+
1. From your project directory, run the following command to download the RIE from GitHub and install it on your local machine.
This command invokes the function running in the container image and returns a response.
99
+
100
+
## How to configure
37
101
38
102
`aws-lambda-rie` can be configured through Environment Variables within the local running Image.
39
103
You can configure your credentials by setting:
40
-
* AWS_ACCESS_KEY_ID
41
-
* AWS_SECRET_ACCESS_KEY
42
-
* AWS_SESSION_TOKEN
43
-
* AWS_REGION
104
+
*`AWS_ACCESS_KEY_ID`
105
+
*`AWS_SECRET_ACCESS_KEY`
106
+
*`AWS_SESSION_TOKEN`
107
+
*`AWS_REGION`
44
108
45
109
You can configure timeout by setting AWS_LAMBDA_FUNCTION_TIMEOUT to the number of seconds you want your function to timeout in.
46
110
47
111
The rest of these Environment Variables can be set to match AWS Lambda's environment but are not required.
48
-
* AWS_LAMBDA_FUNCTION_VERSION
49
-
* AWS_LAMBDA_FUNCION_NAME
50
-
* AWS_LAMBDA_MEMORY_SIZE
112
+
*`AWS_LAMBDA_FUNCTION_VERSION`
113
+
*`AWS_LAMBDA_FUNCION_NAME`
114
+
*`AWS_LAMBDA_MEMORY_SIZE`
115
+
116
+
## Level of support
117
+
118
+
You can use the emulator to test if your function code is compatible with the Lambda environment, executes successfully
119
+
and provides the expected output. For example, you can mock test events from different event sources. You can also use
120
+
it to test extensions and agents built into the container image against the Lambda Extensions API. This component
121
+
does *not *emulate**the orchestration behavior of AWS Lambda. For example, Lambda has a network and security
122
+
configurations that will not be emulated by this component.
51
123
52
-
Limitations
53
124
54
-
* There is no X-Ray support locally
55
-
* Only supports linux x84-64 architectures
56
-
* The emulator runs in a running container
125
+
* You can use the emulator to test if your function code is compatible with the Lambda environment, runs successfully and provides the expected output.
126
+
* You can also use it to test extensions and agents built into the container image against the Lambda Extensions API.
127
+
* This component does _not_ emulate Lambda’s orchestration, or security and authentication configurations.
128
+
* The component does _not_ support X-ray and other Lambda integrations locally.
129
+
* The component supports only Linux x84-64 architectures.
0 commit comments