In this tutorial, you'll learn how to create a lambda layer to package libraries and other dependencies that you can use with your AWS Lambda functions. Using layers reduces the size of uploaded deployment archives and makes it faster to deploy your code.
https://docs.aws.amazon.com/lambda/la...
—
Facebook: / gokcedbsql
—
Video Transcript:
—
Hi guys, this is Abhi from Gokcedb. In this video, you're going to learn how to add a Python Lambda Layer in AWS. Let's start by navigating to the Lambda service then click on create function and give it a name.
Select Python for runtime then hit create function. In the code Source section, I'm going to copy and paste pre-written Python code that imports the request Library. On lines 5 and 6, I'm grabbing the HTML text from gokcedb.com and printing it out on the console.
Hit deploy then click on test and give your test event a name then hit save. Click on test again to execute your Lambda function and you should receive an error message saying unable to import module name requests. To fix this error, we're going to create a Lambda layer.
I'm going to copy and paste the virtual environment folder from an existing project which has the requests package installed already. Let's rename this folder to Python which is the requirement according to this AWS guide. Feel free to remove any unnecessary folders or libraries that you don't need in this layer.
Right-click on the Python folder and hit compress to create a Python.zip file. Let's go back to the Lambda console then click on layers in the left menu then hit create a layer. Give your layer a name then upload the Python.zip file that we just created.
Select comparable architectures and runtimes then hit create. Now go back to your Lambda function then click on layers in the function overview section. Click on add a layer button then choose custom layers.
Choose the custom layer that we just created then hit add. Click on the test button and this time your Lambda function should execute without any errors. As you can see the HTML was printed on the console.
There you have it. Make sure you like, subscribe, and turn on the notification bell. Until next time.
Watch video How To Create Lambda Layer (2 Min) | AWS | Package Python Libraries For Lambda Functions online, duration hours minute second in high quality that is uploaded to the channel Gokce DB 18 January 2023. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 25,335 times and liked it 313 visitors.