aws-lambda-runtime-interface-emulator | Lambda Runtime Interface Emulator is a proxy for Lambda ’ s | Cloud Functions library
kandi X-RAY | aws-lambda-runtime-interface-emulator Summary
kandi X-RAY | aws-lambda-runtime-interface-emulator Summary
The Lambda Runtime Interface Emulator is a proxy for Lambda’s Runtime and Extensions APIs, which allows customers to locally test their Lambda function packaged as a container image. It is a lightweight web-server that converts HTTP requests to JSON events and maintains functional parity with the Lambda Runtime API in the cloud. It allows you to locally test your functions using familiar tools such as cURL and the Docker CLI (when testing functions packaged as container images). It also simplifies running your application on additional computes. You can include the Lambda Runtime Interface Emulator in your container image to have it accept HTTP requests instead of the JSON events required for deployment to Lambda. This component does not emulate 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.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of aws-lambda-runtime-interface-emulator
aws-lambda-runtime-interface-emulator Key Features
aws-lambda-runtime-interface-emulator Examples and Code Snippets
Community Discussions
Trending Discussions on aws-lambda-runtime-interface-emulator
QUESTION
I have a small app (just testing it out for now) written in typescript and I would like to deploy to lambda. I have followed the official tutorial for creating lambda container images in AWS official guide. I have only changed the location of the handler to src/index.ts
When I run curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
I get curl: (56) Recv failure: Connection reset by peer
.
Dockerfile
...ANSWER
Answered 2022-Jan-06 at 12:51The problem was that when building the image I mapped port 9000
to 8000
when the container application binds to 8080
. It solved the issue by changing:
QUESTION
I'm following the instructions to locally test lambda container https://docs.aws.amazon.com/lambda/latest/dg/images-test.html
but I am unable to do so.
I've created a sample project to reproduce it https://gitlab.com/sunnyatticsoftware/sandbox/lambda-dotnet5-webapi (see the README for step by step on its generation)
Basically I am using an Amazon dotnet template that generates an AWS Lambda function as a .NET 5 web api using containers.
It's all good with the project. The Dockerfile is described as
...ANSWER
Answered 2021-Feb-22 at 15:32The lambda docker images for dotnet already include the RIE, so it's enough with the following (see repo with further details):
To build image
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install aws-lambda-runtime-interface-emulator
You can build RIE into a base image. Download the RIE from GitHub to your local machine and update your Dockerfile to install RIE. 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. Otherwise, the script runs the runtime interface emulator. The following example shows a typical script for a Node.js function. #!/bin/sh if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then exec /usr/local/bin/aws-lambda-rie /usr/bin/npx aws-lambda-ric else exec /usr/bin/npx aws-lambda-ric fi. To use the default x86_64 architecture ADD aws-lambda-rie /usr/local/bin/aws-lambda-rie ENTRYPOINT [ "/entry_script.sh" ]. To use the arm64 architecture: ADD aws-lambda-rie-arm64 /usr/local/bin/aws-lambda-rie ENTRYPOINT [ "/entry_script.sh" ].
Create a script and save it in your project directory. Set execution permissions for the script file.
Download the runtime interface emulator for your target architecture (aws-lambda-rie for x86_64 or aws-lambda-rie-arm64 for arm64) from GitHub into your project directory.
Install the emulator package and change ENTRYPOINT to run the new script by adding the following lines to your Dockerfile:
Build your image locally using the docker build command. docker build -t myfunction:latest .
Run your image locally using the docker run command. docker run -p 9000:8080 myfunction:latest
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page