Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • DSA
  • Practice Problems
  • C
  • C++
  • Java
  • Python
  • JavaScript
  • Data Science
  • Machine Learning
  • Courses
  • Linux
  • DevOps
  • SQL
  • Web Development
  • System Design
  • Aptitude
  • GfG Premium
Open In App
Next Article:
Amazon Web Services - Creating a Lambda Function
Next article icon

Amazon Web Services - Creating a Lambda Function

Last Updated : 13 Apr, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

Pre-Requisites: AWS

AWS Lambda is one of the compute services that helps you to run code without provisioning or managing resources servers. With lambda, user can run their code on a high-availability computing infrastructure. Lambda performs all the tasks related to the administration of the compute resources, which includes the servers and operating system maintenance, automatic scaling, and logging. It also facilitates automatic scaling. With the help of Lambda, users can run their code for virtually any type of application or backend service. Lambda supports many programming languages, all you need to do is supply your code. Users can organize their code into Lambda functions. and these Lambda functions will run your function only once you needed and then automatically scales, and there is a very good option of servicing from a few requests per day to thousands per second. Only you need to pay for the compute time that your code will take to run as there is no charge for the lambda function code when your code is not running. But when you are using Lambda,  you are the only one responsible for your code. Lambda will automatically manage memory, CPU, network and other resources need to run your code.

AWS Lambda is a computing service provided by AWS that will make sure that your Lambda function will be executed only when it is triggered or when it is needed and it also automatically scales your Lambda function for thousands of requests per second. You can attach the events of other AWS services such as creating or updating Dynamo DB tables, uploading files to S3 Bucket, hitting HTTP method endpoints, and so on to your Lambda function and trigger when that event occurs.

How To Launch Lambda Functions From The AWS Console

Step 1: Log in to your AWS account. Once you are redirected to the AWS management console. Click on the Search bar and Search for Lambda. Select the Lambda option in the list.

Search lambda
 

Step 2: In a while, you will be directed to the AWS lambda dashboard page and there you can find create function option click on it.

Create lambda function
 

Step 3: You will then land on the page which is shown below. There are several options available for creating functions such as Author from Scratch, Use a Blueprint, Container Image, and Browse serverless app repository. To begin working with Lambda functions, let's become familiar with these options.

  • Author from scratch: You'll begin with a straightforward "Hello World" example and be able to put your function into use on your own after that.
  • Use a blueprint: An example of code from a blueprint demonstrates how to utilize Lambda with an AWS service or a well-known third-party application. For the Node.js and Python runtimes, blueprints offer sample code and function configuration defaults.
  • Container image: With the help of the Container image option we can run Docker Container in AWS Lambda which already contains API and necessary dependencies like Operation system (OS) and required software. 
  • Browse serverless app repository: Without creating or managing servers, we can execute our application with the aid of the Browse serverless app repository.

Choose the Author from the Scratch option among the available options. In the Basic Information section, you can give any function name for your lambda function. We are giving the name "myFunction". Next, choose your runtime environment, we are leaving it as the default option "Nodejs 14. x".

Configure lambda function
 

Step 4: In the permissions section, you can notice the change default execution role option. Click on it to expand and view the options. you can see various options there You can create a lambda function with a custom role that exists already using the "Use an existing role" option. Using the "Create a new role from AWS policy templates" option you can create a new role by giving the role name and selecting the policy templates doing so creates a new role and gives that role to the lambda function while creating the function. You can select "Create a new role with basic Lambda permissions" click on the "Create function" option and click on Create function.  

Select role and Create function
 

Step 5: In a while, your Lambda function will be created and you will land on your Lambda function and it will look like below. you can see the lambda function code which returns a response of "Hello from Lambda"  below in the Code source section. You can add the Events of other AWS services which should trigger this lambda function by clicking the "Add trigger" option in the Function overview section as shown in the below figure.

Add trigger
 

AWS Lambda Pricing

The price of AWS Lambda is based on the number of requests for your functions and the duration, in seconds, that it takes to execute those requests. Requests are charged at a rate of $0.20 per 1 million requests, and duration is charged at a rate of $0.00001667 per GB-second.In addition to these charges, you may also incur charges for the use of other AWS services, such as Amazon S3 or Amazon DynamoDB, which your functions may access while executing.

AWS Lambda also offers a free tier that allows you to run up to 1 million requests per month and 400,000 GB-seconds of compute time per month at no charge. This free tier can be a great way to get started with AWS Lambda and try out the service without incurring any charges. Overall, the cost of using AWS Lambda will depend on the specific use case and the resources required to run your code. It is a good idea to carefully consider your usage patterns and plan your budget accordingly to ensure that you are not overpaying for your computing needs.


Next Article
Amazon Web Services - Creating a Lambda Function

R

ranjithjupaka
Improve
Article Tags :
  • Cloud Computing
  • Geeks-Premier-League-2022

Similar Reads

    Introduction to Amazon Web Services
    Amazon Web Services (AWS) is one of the world's leading cloud platforms in providing the web services of various domains. AWS follows the trends of digital IT and comes up needy services with optimized performances covering a wide range of services from Compute to Storage. It covers a wider range of
    12 min read
    Amazon Web Service - Introduction to API Gateway
    Firstly, API stands for Application Program Interface. An API Gateway is a management tool that acts as an interface between users and microservices. The Amazon API Gateway is an AWS service that allows users to create, publish, secure, maintain and monitor APIs at any scale. You can create APIs in
    12 min read
    AWS Lambda Functions With AWS CLI
    Amazon Web Services (AWS) is a comprehensive cloud computing platform offering many services, including storage, computing, databases, and more. AWS Lambda is a serverless computing service provided by Amazon Web Services (AWS). we can create functions and self-contained applications.With AWS Lambda
    5 min read
    Function as a Service (Faas) - System Design
    Function as a Service (Faas) is an important approach to software development where you create small, specialized functions to handle specific tasks. Instead of building entire applications, developers focus on writing these functions, which are then executed in response to events or requests. This
    11 min read
    How to Use AWS Lambda Function to Access an Amazon RDS Database?
    AWS lambda is a managed serverless deployment service of AWS which can be used for implementation of various applications in cloud. AWS RDS is relational database management system that supports various vendors. In this article we will see how we can create and access Amazon RDS database through a l
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences