awslambda

A package to compile nim functions for AWS Lambda

Pure Nim score 30/100 · tests present · docs generated

Summary

Latest Version Unknown
License MIT
CI Status Passing
Downloads 0
Last Indexed 2026-07-21 05:24

Tags

Installation

nimble install awslambda
choosenim install awslambda
git clone https://github.com/lambci/awslambda.nim

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
awslambda - - - - - - -

Source

Repository https://github.com/lambci/awslambda.nim
Homepage https://github.com/lambci/awslambda.nim
Documentation View Documentation
Registry Source nimble_official

README

Nim on AWS Lambda

Write your Lambda functions in nim using the custom runtime and get tiny binaries (250kb) and single-digit millisecond cold starts!

Log output

Function Example

Create a bootstrap.nim with the following:

import awslambda, json, times

proc handler(event: JsonNode, context: LambdaContext): JsonNode =
  echo "Hi from nim! Invocation will timeout at: ", context.deadline.format("yyyy-MM-dd'T'HH:mm:ss'.'fff")

  event["newKey"] = %*"newVal"

  event


when isMainModule:
  startLambda(handler)

Compiling

# if you're using Linux, you probably don't need to compile in docker, but assuming you're not:

docker run --rm -v "$PWD":/app -w /app nimlang/nim \
  sh -c 'nimble install -y awslambda && nim c -d:release bootstrap.nim'

zip -yr lambda.zip bootstrap # and anything else your binary needs

Then upload lambda.zip as the function code for your (custom runtime) Lambda.

Documentation

startLambda

proc startLambda*(handler: proc(event: JsonNode, context: LambdaContext): JsonNode)

This processes the event processing loop and takes a handler proc that should take the form:

proc handler(event: JsonNode, context: LambdaContext): JsonNode

LambdaContext

Each invocation will also have the following context object populated:

type
  LambdaContext* = tuple
    functionName: string
    functionVersion: string
    memoryLimitInMb: int
    logGroupName: string
    logStreamName: string
    awsRequestId: string
    invokedFunctionArn: string
    deadline: Time
    identity: JsonNode
    clientContext: JsonNode