Create A Deployment Package

Create A Deployment Package

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed layers in a lambda function. We have also created a layer for python package pymysql and used that package in our lambda function.

In this blog post, we will create a deployment package for our lambda function containing our function definition along with the dependent package. The function definition and package are the same as the previous post, only we are deploying the package directly within the function instead of using layers.

Create A Deployment Package

Step 1: Login to EC2 instance and create the deployment package

# create module directory
mkdir pymysql

# get inside the directory
cd pymysql

# install pymysql module
pip install pymysql -t .

# create a zip file using installed module
zip -r9 ../ .

# get to the parent directory
cd ..

# create with lambda function definition

# include in the
zip -g

# update the existing function using AWS CLI
aws lambda update-function-code --function-name myfunction --zip-file fileb://

Step 2: Login to AWS console and check your function definition.

Create A Deployment Package

Observe: Lambda function successfully updated with the deployment package containing pymysql package along with

Step 3: Test the function by uploading an object into the S3 bucket.

Create A Deployment Package

Step 4: Check CloudWatch Logs.

Create A Deployment Package

Observe: Our lambda function with module pymysql successfully executed.

Hope you have enjoyed this article. In the next blog post, we will execute the lambda function from the AWS console.

To get more details on Lambda, please refer below AWS documentation


Leave a Reply

Close Menu