Hi, everyone, and welcome back.
Now, in today's video, we are going to discuss about the Lambda deployment package.
Now, when we discuss about the production environment code that gets deployed at a lambda level, note
that the functions code can consist of scripts or even compiled programs and their associated dependencies.
So when we discuss about dependency, it can be any package, module or other assembly dependency that
is not included with the Lambda runtime environment for your function's code.
So in such cases, if you want to deploy your overall program, what you can do along with the application
code, you can include the appropriate dependencies and modules and together you can package it and
then add it as part of lambda.
So this packaging of your application code, along with its dependencies and modules, is referred to
as a deployment package.
So at a high level overview, a deployment package acts as a source bundle to your Lambda functions
code.
So if you look into this screenshot, you have your function code, which is the Python base p file,
and along with that there are certain set of dependencies that are also added as part of the overall
deployment package.
So let's do one thing.
Let's go ahead and look into this from a practical point of view.
Now for today's demo, I have a folder demo function and within here I have a file called Lambda underscore
function.
It is a Python based file.
Let's quickly open this up.
And if you look into the code here, you have a import of request and in the response, the website
is based on google.com.
Now, at this stage, when you go ahead and upload this code at a lambda level, let's quickly try it
out.
So let me quickly create a lambda function.
I'll just call it as demo function and let's choose the runtime to be Python and I'll create a function.
All right.
So the function is created.
So at this stage, when you copy this specific code snippet, let's add it as part of our code here
and let's deploy it all right once, then you can go ahead and test it.
Let's do a test.
At this stage you see it states execution field and the message is unable to import module, no module
name request.
So at this stage we can consider it to be a missing dependency or module that the code requires, but
the lambda is not able to find.
So what you can do, you can package both the application code and its associated dependencies, modules,
etc. and in total you upload the deployment package to Lambda.
Now from the ClA, I already have PIP available again, if you don't have it available, that is also
fine.
You can just go through the demo.
I'll just quickly install request and a target.
I'll set it to same directory.
All right.
Now if you look into that demo function, apart from our Python code, you have certain additional folders
that are also available.
All right.
So with these set of modules are function will work perfectly well.
So what we will be doing will be packaging it.
So let's.
Package it to a zip file.
So this is the zip file.
And for our lambda function, let's go ahead and upload from the zip file.
All right, so the demo function zip file that I have available, I'll upload it here.
And this time, you see, apart from our lambda function p file, you also have all the appropriate
modules that are available.
So once this is, then you can go ahead and quickly test it.
Let's rerun the test.
And this time, you see execution is succeeded.
And in the response, we are seeing the appropriate response.
Now, one important part to note is that Lambda supports two types of deployment packages.
One is the container images, and second is the zip files.
The approach that we had used was the zip archive.
However, in case if you want to prefer a container based approach, this is also something that can
be used.
So that's the high level overview about the deployment package.
And with this will conclude today's video.