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
The Lambda Runtime Interface Emulator is a proxy for Lambda’s Runtime and Extensions APIs, which allows customers to
6
8
locally test their Lambda function packaged as a container image. It is a lightweight web-server that converts
@@ -12,6 +14,21 @@ requests instead of the JSON events required for deployment to Lambda. This comp
12
14
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.
13
15
14
16
17
+
## Content
18
+
*[Installing](#installing)
19
+
*[Getting started](#getting-started)
20
+
*[Test an image with RIE included in the image](#test-an-image-with-rie-included-in-the-image)
21
+
*[To test your Lambda function with the emulator](#to-test-your-lambda-function-with-the-emulator)
22
+
*[Build RIE into your base image](#build-rie-into-your-base-image)
23
+
*[To build the emulator into your image](#to-build-the-emulator-into-your-image)
24
+
*[Test an image without adding RIE to the image](#test-an-image-without-adding-rie-to-the-image)
25
+
*[To test an image without adding RIE to the image](#to-test-an-image-without-adding-rie-to-the-image)
26
+
*[How to configure](#how-to-configure)
27
+
*[Level of support](#level-of-support)
28
+
*[Security](#security)
29
+
*[License](#license)
30
+
31
+
15
32
## Installing
16
33
17
34
Instructions for installing AWS Lambda Runtime Interface Emulator for your platform
@@ -26,26 +43,26 @@ Instructions for installing AWS Lambda Runtime Interface Emulator for your platf
26
43
27
44
## Getting started
28
45
29
-
There are a few ways you use the Runtime Interface Emulator (RIE) to locally test your function depending on the base image used.
46
+
There are a few ways you use the Runtime Interface Emulator (RIE) to locally test your function depending on the base image used.
30
47
31
48
32
49
### Test an image with RIE included in the image
33
50
34
-
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.
51
+
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.
35
52
36
53
#### To test your Lambda function with the emulator
37
54
38
-
1. Build your image locally using the docker build command.
55
+
1. Build your image locally using the docker build command.
39
56
40
57
`docker build -t myfunction:latest .`
41
58
42
-
2. Run your container image locally using the docker run command.
59
+
2. Run your container image locally using the docker run command.
43
60
44
61
`docker run -p 9000:8080 myfunction:latest`
45
62
46
-
This command runs the image as a container and starts up an endpoint locally at `localhost:9000/2015-03-31/functions/function/invocations`.
63
+
This command runs the image as a container and starts up an endpoint locally at `localhost:9000/2015-03-31/functions/function/invocations`.
47
64
48
-
3. Post an event to the following endpoint using a curl command:
65
+
3. Post an event to the following endpoint using a curl command:
@@ -59,10 +76,11 @@ You can build RIE into a base image. Download the RIE from GitHub to your local
59
76
60
77
1. Create a script and save it in your project directory. Set execution permissions for the script file.
61
78
62
-
The script checks for the presence of the `AWS_LAMBDA_RUNTIME_API` environment variable, which 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.
79
+
The script checks for the presence of the `AWS_LAMBDA_RUNTIME_API` environment variable, which 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.
63
80
64
-
The following example shows a typical script for a Node.js function.
65
-
```
81
+
The following example shows a typical script for a Node.js function.
@@ -71,74 +89,83 @@ The following example shows a typical script for a Node.js function.
71
89
fi
72
90
```
73
91
74
-
2. Download the [runtime interface emulator](https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest) for your target architecture (`aws-lambda-rie` for x86\_64 or `aws-lambda-rie-arm64` for arm64) from GitHub into your project directory.
92
+
2. Download the [runtime interface emulator](https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest) for your target architecture (`aws-lambda-rie`for x86\_64 or `aws-lambda-rie-arm64`for arm64) from GitHub into your project directory.
75
93
76
94
3. Install the emulator package and change `ENTRYPOINT` to run the new script by adding the following lines to your Dockerfile:
This command invokes the functionrunningin the container image and returns a response.
131
158
132
-
## How to configure
159
+
## How to configure
133
160
134
-
`aws-lambda-rie` can be configured through Environment Variables within the local running Image.
161
+
`aws-lambda-rie` can be configured through Environment Variables within the local running Image.
135
162
You can configure your credentials by setting:
136
163
*`AWS_ACCESS_KEY_ID`
137
164
*`AWS_SECRET_ACCESS_KEY`
138
165
*`AWS_SESSION_TOKEN`
139
166
*`AWS_REGION`
140
167
141
-
You can configure timeout by setting AWS_LAMBDA_FUNCTION_TIMEOUT to the number of seconds you want your function to timeout in.
168
+
You can configure timeout by setting `AWS_LAMBDA_FUNCTION_TIMEOUT` to the number of seconds you want your functionto timeout in.
142
169
143
170
The rest of these Environment Variables can be set to match AWS Lambda's environment but are not required.
144
171
* `AWS_LAMBDA_FUNCTION_VERSION`
@@ -147,17 +174,16 @@ The rest of these Environment Variables can be set to match AWS Lambda's environ
147
174
148
175
## Level of support
149
176
150
-
You can use the emulator to test if your function code is compatible with the Lambda environment, executes successfully
151
-
and provides the expected output. For example, you can mock test events from different event sources. You can also use
152
-
it to test extensions and agents built into the container image against the Lambda Extensions API. This component
153
-
does *not *emulate* *the orchestration behavior of AWS Lambda. For example, Lambda has a network and security
154
-
configurations that will not be emulated by this component.
155
-
177
+
You can use the emulator to test if your function code is compatible with the Lambda environment, executes successfully
178
+
and provides the expected output. For example, you can mock test events from different event sources. You can also use
179
+
it to test extensions and agents built into the container image against the Lambda Extensions API. This component
180
+
does _not_ emulate the orchestration behavior of AWS Lambda. For example, Lambda has a network and security
181
+
configurations that will not be emulated by this component.
156
182
157
183
* You can use the emulator to test if your function code is compatible with the Lambda environment, runs successfully and provides the expected output.
158
184
* You can also use it to test extensions and agents built into the container image against the Lambda Extensions API.
159
-
* This component does _not_ emulate Lambda’s orchestration, or security and authentication configurations.
160
-
* The component does _not_ support X-ray and other Lambda integrations locally.
185
+
* This component does _not_ emulate Lambda’s orchestration, or security and authentication configurations.
186
+
* The component does _not_ support X-ray and other Lambda integrations locally.
161
187
* The component supports only Linux, for x86-64 and arm64 architectures.
0 commit comments