AWS, Cloud Computing

4 Mins Read

Deploy Packages in Lambda Function Using Wheel File in 3 Steps

Voiced by Amazon Polly

Overview

Sometimes we get stuck in deploying the packages in the Lambda function. Here is the simple way to do it without the need for CLI.

Now, let’s have a simple python code where we want to deploy the Pandas package in the Lambda function, but we got an error.

  • We have a simple code where we import pandas.
    overview1
  • Now test this code so we get the output with an error because we have no pandas package inside the lambda function.
    overview2

You just have to follow some simple steps, let’s get started.

Customized Cloud Solutions to Drive your Business Success

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

Step-by-Step Guide

STEP 1 – Download wheel files from PyPI.org

  • Download the wheel file from the org website . We are now deploying pandas so we download the pandas wheel file from the given website.
  • pandas – This is our main file for the package.

step1

  • Now click on save to download this file.

step1b

STEP 2 – Unzip the wheel file and make a python zip file

  • This is the most important step because we have to unzip the file and we have two ways to do it.
  • One is by installing the wheel package in your python library and unzipping the wheel file with the python “unpack” command. (unpack + “file name”)

step2

  • But if you are not comfortable with the above way then, the second way is very simple you just have to unpack it through an online website. You will not use CLI here. It is suggested that using the website Extract WHL Files Online – ezyZip extract wheel files.

Here, you must click on “Select whl file to open” to upload your wheel file.

step2b

  • After uploading your wheel file, you have to click on the “Save all” option to unzip that wheel file in a specific folder.

step2c

  • You have to make a new combined folder (PYTHON PACKAGE) where all the data of the wheel file is stored After that you have to zip the file as shown below.

step2e

  • Finally, you have the Python package zip file. Here we end with Step 2.

step2f

  • Finally, you have the Python package zip file. Here we end with Step 2.

STEP 3 – Create a layer and attach it to the lambda function

  • We are in the final step so now go to the Lambda function where you find the layer option.

step3

  • Create a layer.

step3b

step3c

  • Your layer is successfully created. You can see it in the below image

step3d

  • Go to your lambda function, scroll down and you will find the Layers option where you have to add a layer in it.

step3e

  • Click on the AWS layer and choose the layers.

step3f

  • Select “AWSDataWrangler-Python3.9” for the Lambda layer and select the layer version and click on ADD.

step3g

  • Finally, you have added both layers successfully.

step3h

  • Everything is perfectly set up. So, without wasting any time let’s “Test” our python code of the Lambda function.

step3i

Hurray! It works! so by these few steps, you can easily deploy any package in the lambda function without any issue. I hope you find it easy.

Conclusion

Lambda layers are an integral tool to use whenever you are developing a Lambda function that uses a third-party Python package. If AWS maintains a pre-built layer that satisfies your needs, it’s the best option to use that layer. I spent more time on this and found this is an easy way to deploy packages in lambda in a simple way. This is a good way to deploy packages if we did not want to use the CLI method.

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

CloudThat is also the official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft gold partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

Drop a query if you have any questions regarding Lambda Function and I will get back to you quickly.

To get started, go through our Consultancy page and Managed Services Package that is CloudThat’s offerings.

FAQs

1. Can we create custom layer without extracting wheel file?

ANS: – No, you must extract the wheel file otherwise you will not get the output.

2. Is it necessary to choose AWS layer?

ANS: – Yes, it every step is necessary and also be sure to choose latest version of AWS layer.

3. What are Wheel files?

ANS: – A WHL file is a package saved in wheel format, which is the standard built-in package format used for Python distribution. It contains all the files for python installation and metadata, including the version of wheel implementation and specification used to package it.

WRITTEN BY Mohd Monish

Monish is working as a Research Associate at CloudThat. He has a working knowledge of multiple different cloud platforms and is currently working on the AWS platform and working on WAR automation, and AWS Media Services. He is interested in research and publishing tech blogs and also exploring new technologies.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!