All Projects → triggermesh → aws-custom-runtime

triggermesh / aws-custom-runtime

Licence: Apache-2.0 license
Knative Function Using the AWS Lambda Runtime API

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to aws-custom-runtime

winepak-sdk
Platform and SDK runtimes for winepak based applications
Stars: ✭ 46 (+6.98%)
Mutual labels:  platform
marcgg.github.com
My personal website & blog
Stars: ✭ 25 (-41.86%)
Mutual labels:  management
actlist-plugin
🔧 Actlist Plugin library to development and debugging.
Stars: ✭ 14 (-67.44%)
Mutual labels:  platform
goose
Personal contents management system.
Stars: ✭ 13 (-69.77%)
Mutual labels:  management
kserve
Serverless Inferencing on Kubernetes
Stars: ✭ 1,621 (+3669.77%)
Mutual labels:  knative
teaful
🍵 Tiny, easy and powerful React state management
Stars: ✭ 638 (+1383.72%)
Mutual labels:  management
QuickNotes
一款简单、轻量、高效的Android记事、记账应用
Stars: ✭ 19 (-55.81%)
Mutual labels:  management
remote-virtualbox
🍰 Little package to do simple things with VirtualBox remotely using it's SOAP API
Stars: ✭ 18 (-58.14%)
Mutual labels:  management
hawtio-integration
Core integration plugins for Hawtio: Apache ActiveMQ, Camel, Karaf, OSGi, and Spring Boot
Stars: ✭ 26 (-39.53%)
Mutual labels:  management
when-i-am-a-leader
Notes and ideas to remember when I am a leader
Stars: ✭ 50 (+16.28%)
Mutual labels:  management
sources-for-knative
VMware-related event sources for Knative.
Stars: ✭ 24 (-44.19%)
Mutual labels:  knative
roxy-wi
Web interface for managing Haproxy, Nginx, Apache and Keepalived servers
Stars: ✭ 1,109 (+2479.07%)
Mutual labels:  management
Port-Able-Suite
🌐 Manager for portable applications
Stars: ✭ 35 (-18.6%)
Mutual labels:  management
streamingfast
The dfuse Blockchain Data Platform
Stars: ✭ 41 (-4.65%)
Mutual labels:  platform
OnceBuilder
OnceBuilder - managment tool, mange projects, templates, plugins in one place.
Stars: ✭ 18 (-58.14%)
Mutual labels:  management
Open-Mam
Open Source Mobile Application Management (WORK IN PROGRESS)
Stars: ✭ 28 (-34.88%)
Mutual labels:  management
k8s-knative-gitlab-harbor
Build container images with Knative + Gitlab + Harbor inside Kops cluster running on AWS
Stars: ✭ 23 (-46.51%)
Mutual labels:  knative
console
HAL management console
Stars: ✭ 41 (-4.65%)
Mutual labels:  management
shd
Show pretty HDD/SSD list
Stars: ✭ 37 (-13.95%)
Mutual labels:  management
assign-one-project-github-action
Automatically add an issue or pull request to specific GitHub Project(s) when you create and/or label them.
Stars: ✭ 140 (+225.58%)
Mutual labels:  management

Go Report Card CircleCI

Running AWS Lambda Custom Runtime in Knative

In November 2018, AWS announced support for Lambda custom runtime using a straightforward AWS lambda runtime API.

In this repository you find a function invoker implemented in Go, which provides the AWS Lambda runtime API. You also find a Knative build template. Using this build template you can run AWS Lambda custom runtimes directly in your Kubernetes cluster using Knative.

The AWS Lambdas execution environment is replicated using the Docker image amazonlinux and some environment variables.

AWS custom runtime walkthrough

This repository contains an example lambda function written in bash with a AWS custom runtime described in this AWS tutorial. To run this function use our tm client to talk to the knative API.

  1. Install AWS custom runtime:
tm deploy task -f https://raw.githubusercontent.com/triggermesh/aws-custom-runtime/main/runtime.yaml
  1. Deploy function:
tm deploy service lambda-bash -f https://github.com/triggermesh/aws-custom-runtime --runtime aws-custom-runtime --build-argument DIRECTORY=example --wait

In output you'll see URL that you can use to access example/function.sh function

AWS Lambda RUST example

RUST is also verified to be compatible with this runtime. Though official readme has build instructions, it is more convenient to use docker.

  1. Clone repository:
git clone https://github.com/awslabs/aws-lambda-rust-runtime
cd aws-lambda-rust-runtime
  1. Build binary and rename it to bootstrap:
docker run --rm --user "$(id -u)":"$(id -g)" -v "$PWD":/usr/src/myapp -w /usr/src/myapp rust:1.31.0 cargo build -p lambda_runtime --example basic --release
mv target/release/examples/basic target/release/examples/bootstrap
  1. Deploy runtime using tm CLI:
tm deploy runtime -f https://raw.githubusercontent.com/triggermesh/aws-custom-runtime/main/runtime.yaml
tm deploy service lambda-rust -f target/release/examples/ --runtime aws-custom-runtime

Use your RUST AWS Lambda function on knative:

curl lambda-rust.default.k.triggermesh.io --data '{"firstName": "Foo"}'
{"message":"Hello, Foo!"}

AWS Lambda C++ example

  1. Build custom runtime:
cd /tmp
git clone https://github.com/awslabs/aws-lambda-cpp.git
cd aws-lambda-cpp
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/tmp/out
make && make install
  1. Prepare example function:
mkdir /tmp/hello-cpp-world
cd /tmp/hello-cpp-world


cat > main.cpp <<EOF
// main.cpp
#include <aws/lambda-runtime/runtime.h>

using namespace aws::lambda_runtime;

invocation_response my_handler(invocation_request const& request)
{
   return invocation_response::success("Hello, World!", "application/json");
}

int main()
{
   run_handler(my_handler);
   return 0;
}
EOF


cat > CMakeLists.txt <<EOF
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_STANDARD 11)
project(bootstrap LANGUAGES CXX)

find_package(aws-lambda-runtime REQUIRED)
add_executable(\${PROJECT_NAME} "main.cpp")
target_link_libraries(\${PROJECT_NAME} PUBLIC AWS::aws-lambda-runtime)
aws_lambda_package_target(\${PROJECT_NAME})
EOF
  1. Build function:
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/tmp/out
make
  1. Deploy with tm CLI:
tm deploy task -f https://raw.githubusercontent.com/triggermesh/aws-custom-runtime/main/runtime.yaml
tm deploy service lambda-cpp -f . --runtime aws-custom-runtime

C++ Lambda function is running on knative platform:

curl lambda-cpp.default.k.triggermesh.io --data '{"payload": "foobar"}'
Hello, World!

Events wrapping

Triggermesh AWS custom runtime supports events wrapping for better interoperability of functions and data originated from or targeted at the different platforms. Currently, there are two events wrapper available besides the default "passthrough" one:

  • API Gateway wrapper ensures that HTTP requests are digestible by the AWS Lambda functions and decodes their responses to the simple readable format
  • CloudEvents wrapper converts function responses into CloudEvents event objects.

Events wrapper can be enabled by setting function's environment variables and may have different set of configurable parameters. Let's take a look at CloudEvens example:

  1. Generate sample Go function using tm CLI

    tm generate go
    
  2. Open go/serverless.yaml deployment manifest and add events wrapper env variables:

    ...
    environment:
       RESPONSE_WRAPPER: CLOUDEVENTS
       CE_TYPE: go-klr-cloudevent
    ...
    
  3. Deploy function:

    tm deploy -f go --wait
    

After CLI report that deployment is succeeded, send a request to the function endpoint:

curl -d '{"Name":"Joe"}' https://go-demo-service-go-function.default.dev.munu.io

The result will be encoded into CloudEvents format:

Validation: valid
Context Attributes,
  specversion: 1.0
  type: go-klr-cloudevent
  source: go-demo-service-go-function
  subject: klr-response
  id: 7fa17c84-56f0-488a-b7de-e45d7fb3b7b1
  datacontenttype: application/json
Data (binary),
  "Hello Joe!"

Support

We would love your feedback on this tool so don't hesitate to let us know what is wrong and how we could improve it, just file an issue

Code of Conduct

This plugin is by no means part of CNCF but we abide by its code of conduct

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].