Skip to content

Readme: Add syntax highlighting, fix typos, other cleanups #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 17, 2023
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Lambda’s orchestrator, or security and authentication configurations. You can
* [Build RIE into your base image](#build-rie-into-your-base-image)
* [To build the emulator into your image](#to-build-the-emulator-into-your-image)
* [Test an image without adding RIE to the image](#test-an-image-without-adding-rie-to-the-image)
* [To test an image without adding RIE to the image](#to-test-an-image-without-adding-rie-to-the-image)
* [How to configure](#how-to-configure)
* [Level of support](#level-of-support)
* [Security](#security)
Expand Down Expand Up @@ -79,7 +80,7 @@ You can build RIE into a base image. Download the RIE from GitHub to your local

The following example shows a typical script for a Node.js function.

```
```sh
#!/bin/sh
if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then
exec /usr/local/bin/aws-lambda-rie /usr/bin/npx aws-lambda-ric
Expand All @@ -94,38 +95,39 @@ You can build RIE into a base image. Download the RIE from GitHub to your local

To use the default x86\_64 architecture

```
```dockerfile
ADD aws-lambda-rie /usr/local/bin/aws-lambda-rie
ENTRYPOINT [ "/entry_script.sh" ]
```

To use the arm64 architecture:

```
```dockerfile
ADD aws-lambda-rie-arm64 /usr/local/bin/aws-lambda-rie
ENTRYPOINT [ "/entry_script.sh" ]
```

4. Build your image locally using the docker build command.

```
```sh
docker build -t myfunction:latest .
```

5. Run your image locally using the docker run command.

```
```sh
docker run -p 9000:8080 myfunction:latest
```

### Test an image without adding RIE to the image

You install the runtime interface emulator to your local machine. When you run the container image, you set the entry point to be the emulator.
*To test an image without adding RIE to the image *

#### To test an image without adding RIE to the image

1. From your project directory, run the following command to download the RIE (x86-64 architecture) from GitHub and install it on your local machine.

```
```sh
mkdir -p ~/.aws-lambda-rie && curl -Lo ~/.aws-lambda-rie/aws-lambda-rie \
https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie \
&& chmod +x ~/.aws-lambda-rie/aws-lambda-rie
Expand All @@ -139,16 +141,18 @@ You install the runtime interface emulator to your local machine. When you run t

2. Run your Lambda image function using the docker run command.

```
docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 myfunction:latest
--entrypoint /aws-lambda/aws-lambda-rie <image entrypoint> <(optional) image command>`
```sh
docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 myfunction:latest \
--entrypoint /aws-lambda/aws-lambda-rie <image entrypoint> <(optional) image command>
```

This runs the image as a container and starts up an endpoint locally at `localhost:9000/2015-03-31/functions/function/invocations`.

3. Post an event to the following endpoint using a curl command:

`curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'`
```sh
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
```

This command invokes the function running in the container image and returns a response.

Expand All @@ -173,10 +177,9 @@ The rest of these Environment Variables can be set to match AWS Lambda's environ
You can use the emulator to test if your function code is compatible with the Lambda environment, executes successfully
and provides the expected output. For example, you can mock test events from different event sources. You can also use
it to test extensions and agents built into the container image against the Lambda Extensions API. This component
does *not *emulate* *the orchestration behavior of AWS Lambda. For example, Lambda has a network and security
does _not_ emulate the orchestration behavior of AWS Lambda. For example, Lambda has a network and security
configurations that will not be emulated by this component.


* You can use the emulator to test if your function code is compatible with the Lambda environment, runs successfully and provides the expected output.
* You can also use it to test extensions and agents built into the container image against the Lambda Extensions API.
* This component does _not_ emulate Lambda’s orchestration, or security and authentication configurations.
Expand Down