The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Member-only story

How to Use AWS Lambda Layers

--

Photo by Omid Kashmari on Unsplash

What are AWS Lambda layers? As we know, AWS Lambda functions allow to execute code in the cloud according to the serverless paradigm. Each serverless cloud application is normally characterized by multiple independent Lambda functions capable of responding to specific events (like rest API, scheduled, triggers). Each Lambda function is defined by its own deployment package which contains its source code and any requirements, such as additional libraries, dependencies and middleware.

In this type of architecture, the AWS Lambda layers allow to introduce the concept of code/dependency reusability, in order to share modules among different functions: the layers are simple packages that can be reused in Lambda and they actually extend the base runtime. Let’s see how to use layers.

AWS Lambda layers 101

How do you prepare an AWS Lambda layer? To show it let’s consider this example: a Lambda built in Python that requires to run a binary application not included in the standard AWS runtime. In our example, the application is a simple bash script.

#!/bin/bash# This is version.sh script 
echo "Hello from layer!"

To create the Layer we need to prepare a ZIP archive with the following structure:

layer.zip 
└ bin/version.sh

--

--

The Startup
The Startup

Published in The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Vittorio Nardone
Vittorio Nardone

Written by Vittorio Nardone

Docebo Learning Analytics team leader — AWS Certified Solutions Architect — AI/ML enthusiast

Responses (1)