MCPcopy Index your code
hub / github.com/aws-samples/aws-lambda-extensions

github.com/aws-samples/aws-lambda-extensions @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
565 symbols 1,375 edges 131 files 310 documented · 55%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

AWS Lambda Extensions

AWS Lambda extensions

AWS Lambda Extensions are a new way for tools to more easily integrate deeply into the Lambda execution environment to control and participate in Lambda’s lifecycle.

You can use extensions to integrate your Lambda functions with your preferred monitoring, observability, security, and governance tools. You can choose from a broad set of tools provided by AWS Lambda partners or you can create your own Lambda extensions.

Extensions use the Extensions API, a new HTTP interface, to register for lifecycle events and get greater control during function initialization, invocation, and shutdown. They can also use environment variables to add options and tools to the runtime, or use wrapper scripts to customize the runtime startup behavior.

For more information on using the features of Lambda extensions, see Using AWS Lambda extensions.

For more information on building Lambda extensions, see Building Extensions for AWS Lambda.

Sample extension demos and examples

In this repository you will find a number of demos and sample projects from AWS and AWS Partners to help you get started with building your own extensions.

AWS examples

Extension Demos

Extension examples by language

Logs API demos and example extensions

  • Go Logs API extension: How to get a basic Logs API extension written in Go up and running. This extension demonstrates registering for the INVOKE and SHUTDOWN events using the Extensions API. It then runs a local HTTP listener and subscribes to a stream of function and platform logs using the Logs API. It buffers them and sends them to S3 periodically.

  • Python Logs API extension: How to get a basic Logs API extension written in Go up and running. This extension demonstrates registering for the INVOKE and SHUTDOWN events using the Extensions API. It then runs a local HTTP listener and subscribes to a stream of function and platform logs using the Logs API. It buffers them and sends them to S3 periodically.

  • Python for Elasticsearch Logs API extension: How to get a basic Logs API extension for Elasticsearch written in Python 3 up and running. This extension demonstrates registering for the INVOKE and SHUTDOWN events using the Extensions API. It then runs a local HTTP listener and subscribes to a stream of function and platform logs using the Logs API. It buffers them and sends them to Elasticsearch periodically.

  • Node.js Logs API extension: How to get a basic Logs API extension written in Go up and running. This extension demonstrates registering for the INVOKE and SHUTDOWN events using the Extensions API. It then runs a local HTTP listener and subscribes to a stream of function and platform logs using the Logs API. It buffers them and sends them to S3 periodically.

  • Demo: Logs to Amazon S3 extension: zip archive: Demo logs extension to receive logs directly from Lambda and send them to S3, see the blog post Using AWS Lambda extensions to send logs to custom destinations. The demo is deployed using AWS SAM.

  • Demo: Logs to Amazon S3 extension: container image : Demo logs extension to receive logs directly from Lambda and send them to S3. This example packages the extension and function as separate container images. The demo is deployed using AWS SAM.

  • Demo: Logs to Kinesis firehose Logs API extension: How to get a basic logs API extension for Amazon Kinesis Data Firehose written in Go. The extension explains the overall approach to streamline and centralize log collection using Amazon Kinesis Data firehose. The extension runs a local HTTP listener and subscribes to a stream of function and platform logs using the Logs API. It buffers them and sends them to Amazon Kinesis Data firehose periodically, which streams logs to Amazon S3. The demo gets deployed using AWS SAM.

Other extension examples

  • Adaptive Batching extension in Go: How to use the Logs API extension written in Go to adaptively batch log data to a destination (S3). The logs are batched up and stored by the extension. Three environment variables with default values dictate when the logs are send to the destination. If any of the conditions are met, the logs queued will be shipped to S3.
  • ADAPTIVE_BATCHING_EXTENSION_SHIP_RATE_BYTES: Logs are shipped to S3 once log size reaches the number of bytes defined
  • ADAPTIVE_BATCHING_EXTENSION_SHIP_RATE_INVOKES: Logs are shipped to S3 once the number of invokes reaches the number defined.
  • ADAPTIVE_BATCHING_EXTENSION_SHIP_RATE_MILLISECONDS: Logs are shipped to S3 once the amount of time elapsed since the last time logs were shipped is exceeded.

  • Inter-process communication extension in Go: A sample extension written in Go that acts as a companion process. The AWS Lambda function can communicate with the extension. This sample extension:

  • Writes to a file at /tmp/test.txt that the Lambda function can read.

  • Starts a local HTTP server at the provided port (default 2772) that replies to requests with "Hello from http server"

  • Crash uploader extension in Go: A sample extension that looks for core dumps in the execution environment /tmp folder and uploads them to an Amazon S3 bucket for later inspection and troubleshooting.

Wrapper script extension examples by language

AWS Lambda Ready Partner examples that are open-source

Coralogix HashiCorp Vault Honeycomb
Coralogix is a machine data analytics SaaS platform that drastically improves the delivery & maintenance process for software providers. The extension provides full integration of Lambda functions with the Coraligix service The HashiCorp Vault extension makes it easy for operators to manage secrets and make them available for developers to use within their function code, without having to make their functions Vault aware. The Honeycomb Lambda extension allows you to send messages from your Lambda function to Honeycomb by just writing JSON to stdout. The extension receives the messages and forwards them to Honeycomb as an event.
View extension code View extension code View extension code
Lumigo New Relic Sumo Logic
Lumigo helps identify functions that are CPU- or network-bound. This allows you to improve their performance by increasing their memory size. An AWS Lambda extension to collect, enhance, and transport telemetry data from your AWS Lambda functions to New Relic. The Sumo Logic extension, along with Sumo Logic's continuous intelligence platform, enables you to get instance visibility into the health and performance of your mission-critical serverless applications.
View extension View extension View extension

Additional examples that are open-source

Available AWS Lambda Ready Partner extensions

  • AppDynamics: The AppDynamics AWS Lambda Extension provides automatic instrumentation of Node.js or Python Lambda functions to provide visibility and alerting on function performance in a broader business context
  • Check Point CloudGuard: Check Point CloudGuard Serverless Protection is a Lambda Layer/Extension-based runtime protection solution providing zero-configuration security for Lambda Functions.
  • Datadog: The Datadog extension brings comprehensive, real-time visibility to your serverless applications. Combined with Datadog’s existing AWS integration, you get metrics, traces, and logs to help you monitor, detect, and resolve issues at any scale.
  • Dynatrace: The Dynatrace AWS Lambda extension delivers end-to-end visibility into traces and metrics and leverages AI for automated error detection and root cause analysis across the entire application stack.
  • Epsagon: Epsagon’s extension listens to invocation events, stores traces, and sends them in parallel to Lambda function executions. This helps reduce the overhead of distributed tracing and improve performance.
  • HashiCorp Vault: The HasiCorp Vault extension makes it easy for operators to manage secrets and make them available for developers to use within their function code, without having to make their functions Vault aware.
  • Lumigo: Lumigo helps identify functions that are CPU- or network-bound. This allows you to improve their performance by increasing their memory size.
  • New Relic: An AWS Lambda extension to collect, enhance, and transport telemetry data from your AWS Lambda functions to New Relic. This lightweight AWS Lambda Extension runs alongside your AWS Lambda

Core symbols most depended-on inside this repo

String
called by 30
go-example-adaptive-batching-extension/agent/metrics.go
Get
called by 17
go-example-adaptive-batching-extension/queuewrapper/queuewrapper.go
send
called by 10
python-example-elasticsearch-extension/extensions/logs_api_elasticsearch_extension/elasticsearch_producer.py
start
called by 9
nodejs-example-lambda-runtime-api-proxy-extension/nodejs-example-lambda-runtime-api-proxy-extension/runtime-api-proxy.mjs
len
called by 7
rust-example-lambda-runtime-api-proxy-extension/src/util/limited_buffer.rs
prettyPrint
called by 6
go-example-crash-uploader-extension/main.go
Put
called by 6
go-example-adaptive-batching-extension/queuewrapper/queuewrapper.go
Len
called by 6
go-example-adaptive-batching-extension/queuewrapper/queuewrapper.go

Shape

Function 221
Method 174
Struct 96
TypeAlias 43
Class 30
Enum 1

Languages

Go61%
Python22%
Rust7%
TypeScript6%
C#2%
Java2%

Modules by API surface

rust-example-lambda-runtime-api-proxy-extension/src/util/limited_buffer.rs18 symbols
kinesisfirehose-logs-extension-demo/logsapi/client.go15 symbols
kinesis-stream-logs-extension-demo/logsapi/client.go15 symbols
go-example-logs-api-extension/logsapi/client.go15 symbols
go-example-logs-api-extension/agent/logger.go15 symbols
go-example-lambda-runtime-api-proxy-extension/src/proxy/proxy.go15 symbols
go-example-telemetry-api-extension/telemetryApi/client.go14 symbols
go-example-adaptive-batching-extension/logsapi/client.go13 symbols
kinesisfirehose-logs-extension-demo/extension/client.go11 symbols
kinesisfirehose-logs-extension-demo/agent/http.go11 symbols
kinesis-stream-logs-extension-demo/extension/client.go11 symbols
kinesis-stream-logs-extension-demo/agent/http.go11 symbols

For agents

$ claude mcp add aws-lambda-extensions \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact