$ show aws-samples/aws-lambda-extensions
This repository contains a collection of AWS Lambda extension examples and demonstrations across multiple programming languages (Go, Python, Node.js, Java, C#, Rust) and wrapper scripts (Bash, Python, Ruby). Each example illustrates how to build a Lambda extension that integrates deeply with the Lambda execution environment using the Extensions API for lifecycle event registration, and the Logs API/Telemetry API for observability data processing. The extensions perform tasks such as forwarding logs to external destinations (S3, Kinesis, Firehose, Elasticsearch, etc.), collecting and sending telemetry data, implementing custom runtime behavior via wrapper scripts, and caching data from AWS services like DynamoDB and Parameter Store. The repository serves as a practical guide for developers to understand and implement Lambda extensions for observability, security, and governance use cases.
The LLM identified 3 files worth highlighting for reuse:
This file implements a reusable client for the AWS Lambda Extensions API. It handles the registration process to receive INVOKE and SHUTDOWN events and provides a blocking event loop to process these events. The client is self-contained, depending only on the Go standard library, and can be easily extracted into other Go-based Lambda extension projects with minimal changes.
This module sets up an HTTP server to receive log batches from the Lambda Logs API. It demonstrates how to create a threaded HTTP listener that processes incoming log data and places it into a queue for further processing. The pattern is applicable to any service that needs to ingest HTTP-delivered batch data and shows good practices in threading and queue management.
This wrapper script illustrates how to modify the Lambda runtime behavior by overriding the AWS_LAMBDA_RUNTIME_API environment variable to proxy requests through a custom intermediary. The pattern is language-agnostic and demonstrates a non-obvious technique for extending or intercepting the Lambda invocation process, useful for creating custom runtimes or injecting additional logic.