Hi, everyone, and welcome back.
Now, in today's video, we are going to discuss about the basics of Lambda Layers.
Now, first, let's look into the overall challenge that the organization used to face post, which
will be discussing the benefits that the Lambda layer provides.
So let's assume that the organizations are running 50 Lambda functions and all of them are based on
Python, and all of the 50 Lambda functions also makes use of same set of base libraries, so they have
same set of dependencies and appropriate modules.
Now, one of the challenges that you'll see over here is you will have a large deployment package size.
Your update will be difficult and even your deployment time will be difficult.
So at this stage it is still confusing.
Let's look into it from the diagrammatic perspective.
So let's assume that you have a function when you have your Python code and you have a certain set of
base libraries here.
Similarly, you have function to again, a python code, same set of base module.
Again you have the function 50.
So like this you have 50 functions, same base module, different code as we can identify over here
is that the base module is the same across all of the functions.
And let's assume that the size of base module is a little big.
So in such cases it will bring a lot of challenges.
For example, it will increase your overall deployment time.
It will also increase the size of the deployment package and update will be difficult.
So now let's assume tomorrow you want to add one more library associated with this.
So you'll have to update the deployment package or all of the functions.
So this is one of the challenges.
And in order to overcome this, you have the lambda layers.
Now, one of the benefits of lambda layer is you can centralize your dependencies and modules and then
you can associate it with the set of functions that you have.
So this centralization that we see over here is referred to as a lambda layer.
So you have one set of lambda layer and this layer can be associated with multiple set of functions.
So tomorrow if you want to update it, you can update it at a lambda layer level.
So your the deployment time will be much more smaller because now you just have your application code
and you also have the oral code reusability.
So with this base set, let's go ahead and look into it from the demo perspective.
Now for today's demo, I have a function called as a layer lambda function.
Let's quickly open this up.
This is based on Python.
Now, again, this is a simple hello from Lambda function.
So now you have an import of JSON here.
Let's go ahead and add one more.
I'll say import of request.
All right.
Once then we'll deploy it.
And let's go ahead and quickly test it out.
I'll just say event is zero one.
I test it as expected.
You are getting an execution result of fail and what it is stating no module named request.
This is fine.
So now what I have done, I have also created a lambda layer.
Let's open this up.
There is a lambda layer called python based libraries and within here you have the appropriate request
modules.
So now what you can do, you can associate this layer with that lambda function and then we'll verify
if a lambda function works.
So let's go ahead, let's go a bit down.
If you see you have the layers, let's quickly add a layer.
We'll select the custom layer, we'll select that python base libraries and the appropriate version.
And then let's go ahead and add it.
Once you have added the layer, let's go ahead and quickly test it again.
This time I'll say event as zero to.
And you see the execution result.
It states succeeded.
And we are getting Halo from Lambda.
Apart from that, one more thing I wanted to show you is that you can add multiple set of layers.
So you have the layers, the custom layers.
So custom layers is something that we had selected.
Now also provides a set of layers related to various set like Lambda Inside extension.
You have the US SDK related, the app config and various others.
So that's the high level overview about the lambda layers.
And with this will conclude today's video.