Skip to content

Commit

Permalink
docs: Add syntax highlighting, fix typos, other cleanups (#82)
Browse files Browse the repository at this point in the history
* Add missing backslash in docker command

* Remove stray "`" from command

* Covert code snippet to code block for consistency

* Remove extraneous newline

* Fix invalid italics and use "_" for consistency

* Change (invalid) italics to header

Make it consistent with the preceding section that says:
"To build the emulator into your image"

Also, the stray whitespace before the final asterisk was incorrect.

* Add syntax highlighting to code blocks

* Add header to content table
  • Loading branch information
jordan-brough authored Jan 17, 2023
1 parent 6c827ea commit 559b115
Showing 1 changed file with 16 additions and 13 deletions.
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

0 comments on commit 559b115

Please sign in to comment.