Voiced by Amazon Polly |
Introduction to AWS Lambda
AWS Lambda is a compute service that lets you run code without provisioning or managing servers. Instead, Lambda runs your code on a high-availability compute infrastructure and performs all of the administration of the compute resources, including server and operating system maintenance, capacity provisioning and automatic scaling, code monitoring, and logging. As a result, you can run code for virtually any application or back-end service with Lambda. All you need to do is supply your code in one of the languages that Lambda supports.
AWS Lambda supports the following languages for now:
- Java
- Python
- C#
- js
- Go
- PowerShell
- Ruby
Customized Cloud Solutions to Drive your Business Success
- Cloud Migration
- Devops
- AIML & IoT
How does AWS Lambda work?
Developers can start using AWS Lambda services by coding directly in Lambda’s code editor, mentioning the conditions that trigger the code, or directly uploading the code.
The code executed on Lambda run time environment is called a Lambda Function.
First of all, you need to create a function and add basic information, such as which programming language to use.
Then you need to decide whether you want to write the code directly or upload the code in the supported programming language in a zip file.
Once the code is uploaded, the service will handle all the patching, capacity scaling, and administration.
The code runs when the trigger invokes the lambda function. Thus, we need to trigger the lambda function with an external AWS service. Ex. S3 bucket
Now, Lambda is ready to trigger your function automatically when an event occurs. It will run the code when the trigger event is called and manage and monitor the servers for you.
Creating your first Lambda Function
Go to AWS console and search for Lambda
Select Lambda and then click on create a function
Now, you have many options. I will go with Author from scratch
Enter the function name and select Python 3.9 which you want to use for this function
Fill in the details as required and click on create the function
Now your function is created
You can write your code or can copy-paste the following code
1 2 3 4 5 6 |
import json def lambda_handler(event, context): message = 'Hello {} {}!'.format(event['first_name'], event['last_name']) return { 'message' : message } |
Use the test button on the top to test your code after deploying it
Create the test as follows
Click on Save and then Test.
Go to the execution tab and see the result
Now you have your first AWS Lambda code executed.
Conclusion
Lambda is FaaS(Function-as-a-service) by AWS. It also provides a runtime API that helps run functions written in other (native) programming languages. It is a serverless, event-driven compute platform that operates whenever an event occurs. It is auto-scalable, efficiently uses resources, and is managed by AWS.
Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.
- Cloud Training
- Customized Training
- Experiential Learning
About CloudThat
CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.
CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 850k+ professionals in 600+ cloud certifications and completed 500+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training Partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, AWS GenAI Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery Partner, AWS Microsoft Workload Partners, Amazon EC2 Service Delivery Partner, Amazon ECS Service Delivery Partner, AWS Glue Service Delivery Partner, Amazon Redshift Service Delivery Partner, AWS Control Tower Service Delivery Partner, AWS WAF Service Delivery Partner, Amazon CloudFront Service Delivery Partner, Amazon OpenSearch Service Delivery Partner, AWS DMS Service Delivery Partner, AWS Systems Manager Service Delivery Partner, Amazon RDS Service Delivery Partner, AWS CloudFormation Service Delivery Partner, AWS Config, Amazon EMR and many more.
FAQs
1. Can I create a Lambda function for free?
ANS: – Yes. You can create your Lambda function in the free tier of AWS.
2. Are environment variables supported by AWS Lambda?
ANS: – Yes. Environment variables can be easily created and modified from AWS Lambda console, CLI, or SDKs.
3. Is there any way to monitor a Lambda Function?
ANS: – Yes. AWS Lambda Function can be monitored through Amazon CloudWatch.
WRITTEN BY Sonam Kumari
Shambhavi
Mar 23, 2022
Well done