khone/koʊ.neɪ/
Experimental

Example templates

The SAM examples are individually deployable. Each template owns one Khone gateway and the target Lambda functions needed to show a specific integration mode or language.

TemplateShowsStack name
layer-proxy-nodeLayer proxy, Mode A with an unmodified Node handlerkhone-layer-proxy-node
layer-proxy-pythonLayer proxy, Mode A with an unmodified Python handlerkhone-layer-proxy-python
adapter-nodeAdapter, Mode B Node targets for buffered, response-streaming, and SSE-style responseskhone-adapter-node
adapter-rustAdapter, Mode B Rust target for buffered responseskhone-adapter-rust
native-batch-nodeNative batch, Mode C Node handler with fixed, adaptive, target-aware, and streaming routeskhone-native-batch-node

Prerequisites

  • Bootstrap stack deployed from the SAR release, or from source with gateway artifact parameters.
  • Existing LMI capacity provider ARN.
  • SAM CLI, Rust, cargo-lambda, and SAM_CLI_BETA_RUST_CARGO_LAMBDA=1.

Deploy

make examples-sam-deploy GATEWAY_CAPACITY_PROVIDER_ARN=arn:aws:lambda:...

That deploys EXAMPLE_TEMPLATE=adapter-node. Choose another template explicitly:

make examples-sam-deploy \
  EXAMPLE_TEMPLATE=adapter-rust \
  GATEWAY_CAPACITY_PROVIDER_ARN=arn:aws:lambda:...

The Makefile resolves bootstrap exports such as KhoneLayerArm64Arn automatically when a template declares the corresponding parameter. The gateway Lambda code comes from the macro's versioned artifact settings.

Or run SAM directly from one template directory:

cd examples/sam/templates/layer-proxy-python
SAM_CLI_BETA_RUST_CARGO_LAMBDA=1 sam build
sam deploy --parameter-overrides \
  KhoneLayerArm64Arn="$(aws cloudformation list-exports --query 'Exports[?Name==`KhoneLayerArm64Arn`].Value | [0]' --output text)" \
  GatewayCapacityProviderArn="arn:aws:lambda:..."

Try the routes

Use GatewayFunctionUrl as the base URL:

  • layer-proxy-node: GET {GatewayFunctionUrl}layer-proxy/node/hello?max-delay=0
  • layer-proxy-python: GET {GatewayFunctionUrl}layer-proxy/python/hello?max-delay=0
  • adapter-node: GET {GatewayFunctionUrl}adapter/node/buffered/hello?max-delay=0
  • adapter-node: GET {GatewayFunctionUrl}adapter/node/streaming/hello?max-delay=0
  • adapter-node: GET {GatewayFunctionUrl}adapter/node/sse?max-delay=0
  • adapter-rust: GET {GatewayFunctionUrl}adapter/rust/hello?max-delay=0
  • native-batch-node: GET {GatewayFunctionUrl}native-batch/node/buffered/hello?max-delay=0
  • native-batch-node: GET {GatewayFunctionUrl}native-batch/node/adaptive/hello?max-delay=0
  • native-batch-node: GET {GatewayFunctionUrl}native-batch/node/target-aware/hello?max-delay=0
  • native-batch-node: GET {GatewayFunctionUrl}native-batch/node/streaming/hello?max-delay=0

max-delay=0 disables artificial sleep in the sample handlers.