{"id":13646309,"url":"https://github.com/triggermesh/aws-custom-runtime","last_synced_at":"2025-04-21T17:32:29.982Z","repository":{"id":33795216,"uuid":"159801517","full_name":"triggermesh/aws-custom-runtime","owner":"triggermesh","description":"Knative Function Using the AWS Lambda Runtime API","archived":true,"fork":false,"pushed_at":"2023-09-18T10:34:44.000Z","size":332,"stargazers_count":46,"open_issues_count":3,"forks_count":14,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-12-20T00:34:09.122Z","etag":null,"topics":["aws","aws-lambda","knative","kubernetes","management","platform","serverless"],"latest_commit_sha":null,"homepage":"https://triggermesh.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/triggermesh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-30T09:40:55.000Z","updated_at":"2023-12-11T11:05:39.000Z","dependencies_parsed_at":"2024-01-14T09:59:15.088Z","dependency_job_id":"cc2cf656-f986-41e9-96f0-5a97bb5b1a6c","html_url":"https://github.com/triggermesh/aws-custom-runtime","commit_stats":null,"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/triggermesh%2Faws-custom-runtime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/triggermesh%2Faws-custom-runtime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/triggermesh%2Faws-custom-runtime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/triggermesh%2Faws-custom-runtime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/triggermesh","download_url":"https://codeload.github.com/triggermesh/aws-custom-runtime/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250100719,"owners_count":21374991,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-lambda","knative","kubernetes","management","platform","serverless"],"created_at":"2024-08-02T01:02:52.641Z","updated_at":"2025-04-21T17:32:29.117Z","avatar_url":"https://github.com/triggermesh.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/triggermesh/aws-custom-runtime)](https://goreportcard.com/report/github.com/triggermesh/aws-custom-runtime) [![CircleCI](https://circleci.com/gh/triggermesh/aws-custom-runtime.svg?style=shield)](https://circleci.com/gh/triggermesh/aws-custom-runtime)\n\n## Running AWS Lambda Custom Runtime in Knative\n\nIn November 2018, AWS announced support for [Lambda custom runtime](https://aws.amazon.com/about-aws/whats-new/2018/11/aws-lambda-now-supports-custom-runtimes-and-layers/) using a straightforward [AWS lambda runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html).\n\nIn 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](https://github.com/knative).\n\nThe AWS Lambdas execution [environment](https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html) is replicated using the Docker image `amazonlinux` and some environment variables.\n\n### AWS custom runtime walkthrough\n\nThis repository contains an `example` lambda function written in bash with a AWS custom runtime described in this AWS [tutorial](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-walkthrough.html). To run this function use our [`tm`](https://github.com/triggermesh/tm) client to talk to the knative API.\n\n1. Install AWS custom runtime:\n```\ntm deploy task -f https://raw.githubusercontent.com/triggermesh/aws-custom-runtime/main/runtime.yaml\n```\n\n2. Deploy function:\n```\ntm deploy service lambda-bash -f https://github.com/triggermesh/aws-custom-runtime --runtime aws-custom-runtime --build-argument DIRECTORY=example --wait\n```\n\nIn output you'll see URL that you can use to access `example/function.sh` function\n\n\n### AWS Lambda RUST example\n\nRUST is also verified to be compatible with this runtime. Though [official readme](https://github.com/awslabs/aws-lambda-rust-runtime) has build instructions, it is more convenient to use docker.\n\n1. Clone repository:\n```\ngit clone https://github.com/awslabs/aws-lambda-rust-runtime\ncd aws-lambda-rust-runtime\n```\n\n2. Build binary and rename it to `bootstrap`:\n```\ndocker 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\nmv target/release/examples/basic target/release/examples/bootstrap\n```\n\n3. Deploy runtime using [`tm`](https://github.com/triggermesh/tm) CLI:\n```\ntm deploy runtime -f https://raw.githubusercontent.com/triggermesh/aws-custom-runtime/main/runtime.yaml\ntm deploy service lambda-rust -f target/release/examples/ --runtime aws-custom-runtime\n```\n\nUse your RUST AWS Lambda function on knative:\n\n```\ncurl lambda-rust.default.k.triggermesh.io --data '{\"firstName\": \"Foo\"}'\n{\"message\":\"Hello, Foo!\"}\n```\n\n### AWS Lambda C++ example\n\n1. Build custom runtime:\n```\ncd /tmp\ngit clone https://github.com/awslabs/aws-lambda-cpp.git\ncd aws-lambda-cpp\nmkdir build\ncd build\ncmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/tmp/out\nmake \u0026\u0026 make install\n```\n\n2. Prepare example function:\n```\nmkdir /tmp/hello-cpp-world\ncd /tmp/hello-cpp-world\n\n\ncat \u003e main.cpp \u003c\u003cEOF\n// main.cpp\n#include \u003caws/lambda-runtime/runtime.h\u003e\n\nusing namespace aws::lambda_runtime;\n\ninvocation_response my_handler(invocation_request const\u0026 request)\n{\n   return invocation_response::success(\"Hello, World!\", \"application/json\");\n}\n\nint main()\n{\n   run_handler(my_handler);\n   return 0;\n}\nEOF\n\n\ncat \u003e CMakeLists.txt \u003c\u003cEOF\ncmake_minimum_required(VERSION 3.5)\nset(CMAKE_CXX_STANDARD 11)\nproject(bootstrap LANGUAGES CXX)\n\nfind_package(aws-lambda-runtime REQUIRED)\nadd_executable(\\${PROJECT_NAME} \"main.cpp\")\ntarget_link_libraries(\\${PROJECT_NAME} PUBLIC AWS::aws-lambda-runtime)\naws_lambda_package_target(\\${PROJECT_NAME})\nEOF\n```\n\n3. Build function:\n```\nmkdir build\ncd build\ncmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/tmp/out\nmake\n```\n\n4. Deploy with [`tm`](https://github.com/triggermesh/tm) CLI:\n```\ntm deploy task -f https://raw.githubusercontent.com/triggermesh/aws-custom-runtime/main/runtime.yaml\ntm deploy service lambda-cpp -f . --runtime aws-custom-runtime\n```\n\nC++ Lambda function is running on knative platform:\n```\ncurl lambda-cpp.default.k.triggermesh.io --data '{\"payload\": \"foobar\"}'\nHello, World!\n```\n\n## Events wrapping\n\nTriggermesh 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:\n\n- API Gateway wrapper ensures that HTTP requests are digestible by the AWS Lambda functions and decodes their responses to the simple readable format\n- CloudEvents wrapper converts function responses into [CloudEvents](https://github.com/cloudevents/spec/blob/v1.0/README.md) event objects.\n\nEvents 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:\n\n1. Generate sample Go function using [tm](https://github.com/triggermesh/tm) CLI\n   ```\n   tm generate go\n   ```\n\n1. Open go/serverless.yaml deployment manifest and add events wrapper env variables:\n   ```\n   ...\n   environment:\n      RESPONSE_WRAPPER: CLOUDEVENTS\n      CE_TYPE: go-klr-cloudevent\n   ...\n   ```\n1. Deploy function:\n   ```\n   tm deploy -f go --wait\n   ```\n\nAfter CLI report that deployment is succeeded, send a request to the function endpoint:\n\n```\ncurl -d '{\"Name\":\"Joe\"}' https://go-demo-service-go-function.default.dev.munu.io\n```\n\nThe result will be encoded into CloudEvents format:\n\n```\nValidation: valid\nContext Attributes,\n  specversion: 1.0\n  type: go-klr-cloudevent\n  source: go-demo-service-go-function\n  subject: klr-response\n  id: 7fa17c84-56f0-488a-b7de-e45d7fb3b7b1\n  datacontenttype: application/json\nData (binary),\n  \"Hello Joe!\"\n```\n\n## Support\n\nWe 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](https://github.com/triggermesh/aws-custom-runtime/issues/new)\n\n## Code of Conduct\n\nThis plugin is by no means part of [CNCF](https://www.cncf.io/) but we abide by its [code of conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftriggermesh%2Faws-custom-runtime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftriggermesh%2Faws-custom-runtime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftriggermesh%2Faws-custom-runtime/lists"}