Creating and sharing Lambda layers

Creating and sharing Lambda layers

Greetings,

This article is about Creating and sharing Lambda layers

Objective:

How to Create and share Lambda layers


Services Used:

AWS Lambda

Amazon S3

Introduction:

AWS Lambda is a serverless compute service that runs your code in response to events and automatically manages the underlying compute resources for you.

A Lambda layer is an archive containing additional code, such as libraries, dependencies, or even custom runtimes. When you include a layer in a function, the contents are extracted to the /opt directory in the execution environment.

Benefits of AWS Lambda Layers:

  • You can keep the size of deployments small. Each lambda function can have the code only specific to the action it is intended to perform.
  • Single package for all shared dependencies. No need to package shared dependencies with your lambda functions. Instead, create a layer and reuse with different functions.
  • Easier code updates. If the common dependencies are managed in the layers, then updating the dependency is very easy, as you only need to update the layer in which the dependency is packaged.

STEPS:

Step-1:Creating a AWS Lambda Function

1.Open the AWS Management Console at https://console.aws.amazon.com/ and search for the AWS Lambda

  • Create AWS Lambda Function:

No alt text provided for this image

  • Create Amazon S3 Bucket:

No alt text provided for this image

  • Upload Sample code to Amazon S3 Bucket:

No alt text provided for this image

  • Creating a AWS Lambda Layer

  1. To upload your layer code, do one of the following:

  • To upload a .zip file from your computer, choose Upload a .zip file. Then, choose Upload to select your local .zip file.
  • To upload a file from Amazon S3, choose Upload a file from Amazon S3. Then, for Amazon S3 link URL, enter a link to the file.

No alt text provided for this image

  • Add the layer to your lambda function
  • Run the test in Amazon Lambda Function
  • Conclusion

No alt text provided for this image

The log output will be appear in Amazon CloudWatch as

No alt text provided for this image



To view or add a comment, sign in

Others also viewed

Explore content categories