Sitemap

Aws Lambda Function -Practical

3 min readAug 14, 2022

--

The AWS lambda function is a serverless, event-driven compute service that lets your code run manually without managing servers .AWS lambda function use cases include: file processing,IOT backends , mobile applications, web applications, and real-time streaming .

Press enter or click to view image in full size

Simply write the code and upload it as a.zip file or load it into an s3 bucket. Lambda executes code on a high-availability compute infrastructure and manages all of the administration of the compute resources. As a result, it’s hassle-free to spin up the sources, scale them, and clean them up after the job is complete.

Here I will show you how you can create a lambda function on your own.

Example :- Calling API using aws lambda function

Website link :- https://jsonplaceholder.typicode.com/

API :- 'https://jsonplaceholder.typicode.com/

Step 1 :- Create Lambda Function

Press enter or click to view image in full size

Step 2:- Write lambda function

Press enter or click to view image in full size
lambda_function.py

Step 3 :- Click on Deploy to save the changes .

Get Gaurav’s stories in your inbox

Join Medium for free to get updates from this writer.

Step 4 :- To run this code we also require pip install requests for that we have add that pip install requests on layers of lambda function . For that we have to zip our packages.

Go to your local terminal. write these commands

Step 1 :- mkdir -p layer/python/lib/python3.9/site-pckages

Step 2 : pip install requests -t layer/python/lib/python3.9/site-pckages

Step 3 : cd layer

Step 4 :- zip -r mypackages.zip *

Step 5 :- After Completing Step 4 click on Layers.Create Layer

Press enter or click to view image in full size

Step 6:- After click on add layer. Add your layer.

Press enter or click to view image in full size

Step 7 :- Click on Test (You will get your output).

Press enter or click to view image in full size
Output

Thank you for reading!

I hope this has given you an idea to get started with the Aws lambda function. Please take the time to comment below and let me know your feedback.

--

--

Gaurav
Gaurav

Written by Gaurav

Senior Software Engineer - Data & AI (Ex- Nike , Autodesk ) LinkedIn :- https://www.linkedin.com/in/gauravrawat1412