Getting Started With AWS Lambda

Part - 2 : Creating your first lambda function

30 Days of Node | Node.js Tutorial series



Overview

This is the second part of a 3-part tutorial series on Getting started with amazon Lambda :

  1. In this part, we already learned how we can create a user on our amazon AWS account.
  2. In the second part we will learn how we can create our first lambda function step by step.
  3. In the third part, we will code our lambda function and also we will create our node.js function to call our lambda function.
Prerequisites

  1. Amazon AWS account : You can create Amazon AWS account here or you can login to your account, if u already have one.
  2. User with Lambda full access : You can learn how to create a user with full lambda access here

Creating your first lambda function

  • Step 1 : Select Lambda from the list of all the services provided on the landing page of your aws account as shown in the image below:

    amazon aws lambda function using node.js
  • Step 2 : Click on the create function button to start the process of creating a lambda function as shown in the image below:

    amazon aws lambda function using node.js
  • Step 3 : We can create function in any of the given 3 ways :
    1. Author from scratch:
    2. Blueprint:
    3. Serverless application repository:
    We will build our function from scratch so we will select Author from scratch as shown in the image below:

    amazon aws lambda function using node.js
  • Step 4 : Now add the details in the form for creating a lambda function from scratch.
    1. Name :Name of your function
    2. Runtime : Runtime environment of the function. We are selecting Nodejs 8.10 for our function.
    3. Role : Select Create a custom role from the drop down and it will redirect you to a new page.


    amazon aws lambda function using node.js
  • Step 5 : Fill the fields to provide AWS Lambda access to our AWS resources as shown in the image below:

    amazon aws lambda function using node.js
  • Step 6 : complete the form for creating the lambda fucntion.
    1. Role : Select Choose an existing role from the drop down.
    2. Existing role : Select the rule you created in the previous step.
    Now click on Create function button as shown in image below :

    amazon aws lambda function using node.js
  • Step 7 : Congratulations ! You have successfully created your first lambda function. Now Please note down the location highlighted in the image below for future references.

    amazon aws lambda function using node.js

Understanding Lambda dashboard

  1. Test : We can create test cases for our lambda function here and test our lambda function by clicking on test button.
  2. Save : After making any change, we can save our lambda function by clicking on save button.
  3. Code Entry type : There are 3 ways to write your lambda function provided by amazon AWS :
    • Edit Code Inline :An inline code editor is provided as shown in image below. In the next tutorial we will write our lambda function using that code editor.
    • Upload a .zip file : We can also upload a .zip file with function and supporting node_modules zipped together.
    • Upload a file from amazon s3 :We can also upload a file from amazon s3 which contains lambda function.
  4. Runtime : We can change the runtime environment of the function from this dropdown which contains the list of all the available runtime environments.
  5. Code Editor : This is the online code editor we mentioned in 3rd point.


amazon aws lambda function using node.js

Summary

In this part of the Getting started with AWS lambda functions, we learned about how we can create our first lambda function step by step.