Lambda Extensions: What Are They, And Should You Care?
Tags: cloud, aws, serverless, devops
Published: 2020-10-26 08:07:40

---
title: Lambda Extensions: What Are They, And Should You Care?
published: true
date: 2020-10-26 07:59:54 UTC
tags: cloud, aws, serverless, devops
canonical_url: https://www.thedevcoach.co.uk/aws-lambda-extensions-should-you-care/
---

This month AWS announced a new feature called Lambda Extensions ([Source](https://aws.amazon.com/blogs/compute/introducing-aws-lambda-extensions-in-preview/)). AWS release so many features it is hard to keep up. With each new feature we often need to ask ourselves, is this something we should pay attention to or not?

**What is Lambda Extensions, and who should pay attention to it? Lambda Extensions are an addition to the Lambda Runtime API, allowing additional control, setup and tooling. Lambda Extensions are mainly aimed at third-party vendors, particularly monitoring but also configuration and security. Lambda Extensions will also be interesting to heavy users of AWS Lambda functions who need standardisation or greater control on their setups.**

Now let’s get into more detail on what Lambda Extensions actually are to help you understand whether or not they might be useful in your situation. Let’s start by looking at a core difficulty that Lambda Extensions help solve.

## Why Are Lambda Extensions Useful?

To understand the use case behind Lambda Extensions, let’s take a look at the world before Lambda Extensions using the main use case: monitoring.

In a server world, to extract custom telemetry, it was typical to use an agent, installed in the background of a server to periodically send data to monitoring platforms, hopefully avoiding impact to the application code in the process.

However, in the AWS Lambda world there were only two (not so great) options to achieve similar functionality to an agent:

1. **Synchronous Sending** — Telemetry data is sent during the lifetime of the Lambda function. Sending data synchronously isn’t ideal as it can pass on latencies to the end-user if the function is user-facing.
2. **Asynchronous Sending** — Telemetry data is logged to CloudWatch and processed later by parsing that data within CloudWatch. But, parsing data like this can add additional cost through CloudWatch, and adds a time lag before data arrives in the monitoring platform.

And it’s difficulties like this—sending telemetry data—which influenced AWS to introduce Lambda Extensions. Now, let’s take a look at what Lambda Extensions actually are in practice.

## What is Lambda Extensions?

 ![Lambda Extensions](https://i1.wp.com/www.thedevcoach.co.uk/wp-content/uploads/2020/10/lambdaextensions.png?resize=760%2C509&ssl=1)

Lambda Extensions ([Source](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html))

Lambda Extensions is an addition to the existing runtime API of AWS Lambda. Lambda Extensions allow additional logic to be ran before, during and after a functions invocation. You can use Lambda Extensions for: capturing additional monitoring data, fetching secrets and configuration or running security software.

Lambda Extensions come in two main flavours: internal and external. Internal Extensions run in the same process as the Lambda function, whereas external run in a separate process. Each Lambda Extension type has different pro’s and con’s, i.e external Extensions can be written in a different language to the function since they’re operating a separate process ([Source](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html)).

So by now you might be wondering: “what are some of the practical use cases for Lambda Extensions?”

## Use Cases For Lambda Extensions

There are really three broad categories of use for Lambda Extensions: monitoring, configuration and security.

1. **Monitoring** — Lambda Extensions can be used to send additional telemetry data about a running lambda function whilst having less impact on the behaviour of the running function. For instance, check out [Lumigo’s Lambda extension](https://docs.lumigo.io/docs/lambda-extensions) which extracts data like CPU usage.
2. **Configuration** — Lambda Extensions can be used to help configure and setup a Lambda on start-up, such as by loading in configuration data, such as secrets. For instance, check out this Lamba Extension for [fetching secrets from AWS secrets manager](https://github.com/square/lambda-secrets-prefetch). or this [Lambda Extension that pulls secrets from Hashicorp Vault](https://github.com/hashicorp/vault-lambda-extension).
3. **Security** — Lambda Extensions can be used for security as an additional layer to enforce security restrictions for instance by inspecting requests made from a Lambda function.

Now that we know more about what Lambda Extensions is and the main use cases, you may be thinking about the other details such as as the impact of Lambda Extensions on cost, performance, etc. Let’s cover that now.

## Key Information About Lambda Extensions

Lambda Extensions can have an impact on performance and cost.

- Lambda Extensions are distributed as Lambda Layers.
- There’s a limit of 10 Lambda Extensions per function.
- The size of the Extensions contribute to the 250MB Lambda limit.
- Extensions share resources (CPU, Memory & Network) with the Lambda, meaning Lamba Extensions can impact the performance of a Lambda.
- There’s no additional cost for Lambda Extensions, the cost of Extensions are factored in as part of the resource usage of the Lambda.

And that covers most of what Lambda Extensions are. If you’re interested to know more, I’ve got some links that might be useful for you to check out.

## Useful Resources

- [AWS Announcement 1: Introducing](https://aws.amazon.com/blogs/compute/introducing-aws-lambda-extensions-in-preview/)[ Lambda Extensions](https://aws.amazon.com/blogs/compute/introducing-aws-lambda-extensions-in-preview/)
- [AWS Announcement 2: Building Lambda Extensions](https://aws.amazon.com/blogs/compute/building-extensions-for-aws-lambda-in-preview/)
- [The Lambda Extensions API ](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html)
- [The Lamba Extensions FAQ](https://aws.amazon.com/lambda/faqs/)
- [Lambda Extensions Example Repo](https://github.com/aws-samples/aws-lambda-extensions)

## Should You Care About Lambda Extensions?

And that’s all we’re going to cover for today. I’m hoping you now have a better understanding of what Lambda Extensions are, and you can make a decision about whether they are or aren’t useful to you right now.

Lambda Extensions will be most interesting to you if you’re a third-party or vendor of monitoring, security or configuration. Or, if you work on an internal or a platform team in a company running lots of AWS Lambda functions who want greater control and standardisation of your Lamba functions.

The likelihood for most is that Lambda Extensions aren’t something worth paying too much attention to (just yet). You may find that you integrate them into your existing functions but you shouldn’t need to know all the fine details.

---

The post [Lambda Extensions: What Are They, And Should You Care?](https://www.thedevcoach.co.uk/aws-lambda-extensions-should-you-care/) appeared first on [The Dev Coach](https://www.thedevcoach.co.uk).

If you’re interested in Cloud I write a monthly [newsletter for Cloud Software Engineers](https://newsletter.thedevcoach.co.uk). I spend the month digging around the internet for the best cloud engineering content and provide a monthly summary. I read every article I share, and I focus on fundamentals as much as possible.