This month AWS announced a new feature called Lambda Extensions (Source). 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:
- 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.
- 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 (Source)
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).
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.
- 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 which extracts data like CPU usage.
- 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. or this Lambda Extension that pulls secrets from Hashicorp Vault.
- 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 Lambda Extensions
- AWS Announcement 2: Building Lambda Extensions
- The Lambda Extensions API
- The Lamba Extensions FAQ
- Lambda Extensions Example Repo
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? appeared first on The Dev Coach.
If youâre interested in Cloud I write a monthly newsletter for Cloud Software Engineers. 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.