Who we are

Nethram LLC is a promising name in the field of Telecommunications and Cloud Computing. Based in Silicon Valley, the company has a proud legacy spanning of over 11 successful years of software development. Nethram was born in August 2004 as a brainchild of two professionals Paul Mathews and Helani Mathew. Specialized in Cloud Computing, Telephone Solutions and Interactive TV with VOD, the company believes in the clever use of telecommunications as an effective tool to reach out to a wide mass with powerful, efficient and clear messages across borders. In June 2013, Nethram spread out its branches to India, with the formation of Nethram India Innovation Center Pvt Limited.

Call Us At

1-888-440-3740

Know more

Ethan M

Excellent work, great communication and very precise and detail oriented. Was able to implement on time and on budget! Rare indeed! highly recommended.

Our Blog

AWS Lambda Tutorial: Step by step instructions to create a scalable web application – Part 4

Arunbalan
January 27, 2016
535337722_5fd0c74173_o

Configuring Amazon API Gateway and finishing application

STEP 1: CONFIGURING THE APIS.

Now your lambda functions are ready and functioning. The next step is to enable them to access from the Amazon API Gateway and pass the necessary parameter to each Lambda function.

In the same page where you upload your lambda function click the Get method under the API endpoints tab. Then it directs you to a new page where you can configure your API. A new page will appear as below. Click on your API  (for example –   CreateAccount ).

 

 

  • 105In API Gateway, a mapping template is used to transform some data from one format to another. You create and use input mapping templates when you need to inform API Gateway about the schema of the data that is given to lambda function and you can use output mapping templates for output of the lambda function. You can create models that enable API Gateway to make it easier for you to create mapping templates.
  • Click on the GET method under the Resource tab. You will get a screen like below image.

 

Screenshot from 2016-01-27 00:18:14
    •  Select Method Request from the first box to set the URL Query String Parameters and input model. Click Add query stringunder the URL Query String Parameters section. Enter two  parameters   name and password click and submit . Then set the input model by clicking Add Model, then a new screen will display. Enter the model name as Input Model. In the edit field type the code provided below

      { 
        "$schema": "http://json-schema.org/draft-04/schema#", 
        "title": "CreateAccount", 
        "type": "object", 
        "properties": { 
                       "name": { "type": "string" }, 
                       “password”: {“type”:”string”} 
                      } 
      }

Screenshot from 2016-01-27 00:22:19

Note: Here in this example we are giving two parameters under the properties key, because this model is using for CreateAccountfunction’s API configuration. In order to do the same for UpdateStatus function API we needed to include one more parameter inside the properties. The third parameter is the status parameter.

  • Next Select the Integration Request block and Select the Integration type as Lambda Function, Then Select your lambda function name. You can create a Mapping template under the mapping template section. Under the Content-type tab add application/json and submit. Add codes to mapping template edit window. The sample code is given below.

     { 
       "name": "$input.params(‘name)",
       “password”: “$input.params(“password”)” 
     } 
 Screenshot from 2016-01-27 14:31:20

Now the parameter query string parameter is passed to the here and a new json formatted body is created.

  • Now the parameter required for the lambda function is converted to the well formatted json content. Lambda will pass all parameters after making it as string using JSON.Stringify method. So we need to capture the result and change it into the desired format as we needed.

Select Integration Response section to create an output mapping template. It is similar to the template that we did in Integration Request to create input mapping template. Select the Content-Type as application/json. The HTML page is stored inside a variable. That same string we needed to capture from the lambda function. Follow the code given below


      #set($inputRoot = $input.path('$')) 
      $inputRoot.respon 

Screenshot from 2016-01-27 14:33:47
  • The result is now in JSON format. We need to convert its Content-Type into text/html in order to get an HTML page as output. Otherwise there should be quotes outside the HTML codes.
  • Select Method Response section and add a response model add Content-Type as text/html and create an output model.
  • Enter the output model format in the text field. Example code is given below

     { 
        "$schema": "http://json-schema.org/draft-04/schema#",
        "title": "OutputModel",
        "type": "object",
        "properties": {
                        "resp":{"type":"string"}
                      }
     }
 

 

 

Screenshot from 2016-01-27 14:43:49
    •  Do  the same steps for the other two functions UpdateStatus and getAllStatus . The only difference is that there is an additional parameter required for  the UpdateStatus , ie status . So we should add name,password and status in the URL Query String parameter field of Method Request section. And create a request model and name it as Input then add the input model as the following datas. the only difference from the previous API configuration(CreateAccount) is the presence of status parameter.
 
      {
       "$schema": "http://json-schema.org/draft-04/schema#", 
       "title": "updateStatus", 
       "type": "object", 
       "properties": {
                       "name": { "type": "string" }, 
                       "password":{"type":"string"}, 
                       "status":{"type":"string"}
                     }
      }
 

Add the following template datas in the Integration Request section.


      { 
       "name": "$input.params('name')",
       "password":"$input.params('password')",
       "status" : "$input.params('status')"
      }

The getAllStatus API configuration is same as that of CreateAccount function.

Now the models and mapping templates are ready to use. Next step is deploying the API. There is a button called Deploy APIclick on it. Select a deployment stage and deploy the API . Then you can configure Cache settings, CloudWatch settings and Throttling settings. Invoke url will be displayed on the top of the screen.

  • Now the models and mapping templates are ready to use. Next step is deploying the API. Select a deployment stage and deploy it . Then you can configure Cache settings, CloudWatch settings and Throttling settings. Invoke url will be displayed on the top of the screen.
  • Note down the invoke url. we will send the request to this url from our application.

 

15

 

STEP 2 : CREATE WEB INTERFACE AND UPLOAD IT TO AMAZON S3
  • Everything is ready, now we can invoke the lambda function from a browser by sending the parameter with the invoke url. The sample application interface is located in following link
  • https://s3.amazonaws.com/lambdapackage/LambdaAppFinal/index.html . the code is available herehttps://github.com/Nethram/LambdaDemoApplication/blob/master/index.html
  • Create the application interface. you can refer the given html markups. In index.html file we have given action url of our API endpoint. Replace it with your invoke URL.
  • So the next step is to upload the application interface file to the aws S3. Amazon S3 ( Simple Storage Service ) is an online file storage and web service. The is an button named as Create Bucket. Click on it . The following window will appear.

 

    • 106From the AWS console select S3 from the Storage and Content Delivery section.
    • Give a name to it (example: lambdaApp) and select a region. Then press create button. Then on the next screen there is an option to upload files to S3.  then upload the html file to it.
    • After completing the upload.  write click on the file and select  Properties. Then a window will load on the right side of the page. Select Permission tab from the window. And select the Open/Download   checkbox in the section where grantee name  is set as everyone . Save the changes.
    • Now the page is publically accessible. go to the page and check the functionalities of Your first Lambda Application.
    • The lambda function updates the DynamoDB and RDS and it will return a HTML page to the browser.
16
Your scalable and reliable Lambda application is now ready to use.

AWS Lambda Tutorial: Step by step instructions to create a scalable web application – Part 3

Arunbalan
6937250243_5da87cf012_o

Create and configure Lambda functions and uploading Lambda application packages to AWS

Step 1: Create And Configure the Lambda function.

Sign in to the AWS console and select the Lambda . Then follow the instructions to create a lambda function. This session shows the steps to create first lambda function- CreateAccount  for our application . Follow same steps to create two more functions, that are UpdateStatus andgetAllStatus.

  • Click on Create A Lambda Function button.
  • Select blueprint, choose the  microservice-http-endpoint  blueprint
  • Configure function, specify the following values:
    • Enter a function name (for example,  CreateAccount ).
    • Select Node.js from the  Runtime  list.
    • For the IAM  Role , create a role by choosing the  Basic with DynamoDB  from the list.

This role template has a predefined access policy that grants sufficient permissions for AWS actions that your Lambda function needs.If you need more access permissions for your needs you can  create a new IAM role and assign a name (for example,  lambda_dynamo ) as the execution role. Here we use the predefined template Basic with DynamoDB. Press Allow button then click Next.

  • In Configure endpoints , specify the following values:
    • Give a name to the new API . Here we used the same name of the lambda function (CreateAccount ).  After the API is created, it will appear in the Amazon Gateway console.
    • Leave the  Resource name  as it appears in the console. It maps to the name that you specified for your Lambda function, so do not change this value.Here also we gave the same name of the lambda function( CreateAccount ).
    • Choose a method from the list. Here we have chosen GET method.
    • Leave the default  prod  for  Deployment stage .
    • Choose  Open from the  Security  list.

Note: Make sure you have selected the Open from the Security list. Because we create this function for invoke it from web browsers without authentication process.

You will get a following screen make sure your configurations and click Create function .

 

 

10
Step 2: Creating and Uploading the Lambda Application packages.

There are various options to  deploy lambda function to aws. First one , we can use the editor available in Lambda console. and the second option is  uploading  a lambda package from our local machine to aws as a zip package.  Final option is using lambda package stored in the amazon S3.  In this scenario , we use the second method , that is directly  uploading our lambda package from local machine  to AWS lambda. It is because we are using MySQL database in RDS for this application. For that we need to include additional MySQL module to our package. we can’t do this in the editor available in  Lambda console.

A:Create a Lambda function deployment package

  • Create a folder ( LamdaApp ) in your local machine and create three sub-folders inside it. You may give those names as CreateAccount , UpdateStatus and GetStatus  Respectively. After creating the folders install necessary dependency packages to all these three folders.
  • You need to install Node.js platform.
    • Install the Node.js platform. For more information, go to the Node.js website at http://nodejs.org/.
    • Install dependencies in each folder. First enter in the first folder named CreateAccount and install those required modules.
      • For MySQL module type this in terminal.

                                    sudo npm install mysql

      • For File System module type this line in terminal.

                                    sudo npm install fs

  • This will create a directory called node_modules and install the modules inside it. The mysql module is entirely written in Node.js, and implements an async MySQL.
  • Copy the node_modules folder and paste it to other two folders (UpdateStatus and GetStatus).
  • Now we have 3 folders and their required dependency packages in them. Next step is to create lambda function.

 B: Create lambda function and html contents.

    Inside  each folder create the node.js file and other required files for the execution of the functions such as files containing HTML contents

      CreateAccount

  1. In CreateAccount Folder Create following files. Files contents are available in github .  :https://github.com/Nethram/LambdaDemoApplication
  2. Add contents of the index.js as given in the github file.which contains the actions to be performed after getting required parameters.Modify the  lines 26-30 and add  credentials for your  RDS DB instance that you have created earlier.. Add  the name of DynamoDB table in line number 58.
  3. The successful.txt contains the HTML markups which is to be shown after successfully creating an user account.
  4. The unsuccessful.txt contains the HTML markup that will return after errors occurred.

 

       UpdateStatus

  1. Inside the updateStatus folder Create following files.
  2. Add contents of the index.js as given in the github file.which contains the actions to be performed after getting required parameters such as username, password and status.Modify the  lines 25-29 and add  credentials for your  RDS DB instance that you have created earlier. Add  the name of DynamoDB table in line number 61
  3. The success.txt file contains the HTML markups which is to be shown after successful updating of users status.
  4. The incorrect.txt files contains the HTML content which will show after incorrect user password entry.
  5. The noexistuser.txt  contains the HTML contents which show the given username is not created an account. index.js.

 

       GetAllStatus.

  1. Inside the updateStatus folder Create following files.
  2. Add contents of the index.js as given in the file in github. this is the page which executes when we trigger the lambda.Modify the  lines 26-30 and add  credentials for your  RDS DB instance that you have created earlier.Add  the name of DynamoDB table in line number 71.
  3. The success.txt file contains HTML markups which is to be shown after successful authentication of user credentials. This                  contains the HTML format of returning every user’s status.
  4. The incorrect.txt file contains the HTML content which will show after incorrect user password entry.
  5. The noexistuser.txt  contains the HTML contents which show the given username doesn’t hold an account.

C:Uploading the Lambda package

  • Now we have everything ready inside the LambdaApp folder. The next step is to compress the contents of those three subfolders and make zip files. You need to make sure that you are compressing the contents of each folders and not the folder itself. Upload the zip files to the lambda console of each lambda function. See the image below, there is an option to directly upload your zip packages to it or you can upload the files to amazon S3 then configure the third option. Here we are directly uploading the application package to the lambda.

 

103

 

  •  Test the function by clicking the Action button and select Configure test event  option. then on the next window configuring a sample event by giving the simple JSON body. See this image.

 

104

For example, after uploading the CreateAccount zip package we test the function by giving the parameters such as name and password.   The JSON text event body is like this.


     {
      "name":"janet",
      "password":"janet1234"
     }

  • Click on Save and Test  button. Then the given parameters will be passed to the lambda function and it will execute,ie it will create an user account. The result will be shown in  the console. The console will show error if there is any mistakes in your lambda function code.
  • Check your database table and ensure the new item entry.
  • Follow the same steps to upload and test other two lambda function packages. And use the test event body as follows. For UpdateStatus  function. use this.   
    
         {
            "name":"janet",
            "password":"janet1234",
            “status”: “This is my test status”
         } 
    

    make sure that your dynamoDB table has new entry after the test.

     For  getAllStatus function. use the test event shown in the first example.

 

We will cover the methods to configure API endpoint and upload application to AWS S3  in Part 4

AWS Lambda Tutorial: Step by step instructions to create a scalable web application – Part 2

Arunbalan
maxresdefault

Nuts and Bolts

This  application gives a complete overview of how to use AWS resource (such as DynamoDB and RDS) with Lambda and how to return an HTML page as a  response to every incoming request. Here we are using Amazon RDS for storing user’s account information and Amazon DynamoDB for storing user’s status information. The web app is stored in Amazon S3.  It is important to note that EC2 is not used. Hence there is no reserved infrastructure.
Note: There is no need to use both RDS and DynamoDB simultaneously. This example is using both to show that lambda can interface with both.

We will create 3 lambda functions and invoke these functions from separate API endpoints. The Lambda functions are

  • CreateAccount : This function is used to create an account for the user by receiving username and password.
  • UpdateStatus   : This function receives username, password and status from the user. And update the status after authentication.
  • GetAllStatus    : This function authenticates users and list status of every user.

You are just few steps away from creating your Lambda application.

STEP 1: BEFORE YOU USE AWS LAMBDA FOR THE FIRST TIME, COMPLETE THE FOLLOWING TASKS:
  1. Go to the website https://aws.amazon.com/
  2. Sign up for AWS.
STEP 2: CREATE AMAZON RDS MYSQL  AND DYNAMODB DATABASES.

a. Create and configure RDS MySQL database instance

 

3rd

 

  • Click on Launch a DB Instanceand Select MySQL database engine.
  • In Production panel select Second Option MySOL – use Multi-AZ Deployment and Provisioned IOPS Storage as defaults for high availability and fast, consistent performance. Click next button.
Screenshot from 2016-01-27 22:10:24

 

  • Specify database details in next step. Modify database instance class as you need. Here we select db.t2.micro and availing Multi-AZ Deployment. Under the settings give database name, username and password.
6
  • Note down these RDS credentials,which are required to make DB connection from NodeJS script.
  • Here comes an important configuration setup. In this page given below  you should make the database publically accessible. And choose VPC and  default VPC Security group. Then give a name to your database. Then click Launch DB Instance.

 

7

   

 

 

  • Then your database will be created. You will get the endpoint address from the properties of that instance.
  • Install mysql client and connect to this database using endpoint address, username and password. And add the schema given in our github. (in this demo application. We created a table named as ‘login’ and add three fields >UserId , name and password. UserId is auto incremented and name is the Primary key).
  • Download the schema of RDS database available in github  to your system. Open terminal and type commands as in following formate to import schema to RDS.
  • mysql -h RDSEndPointAddress -P 3306 -u username -p databasename < PathTORDSdatabaseSchema.sql 
    


    For example

    
    mysql -h lambdaInstance.cukvxrgt8kqg.us-east-1.rds.amazonaws.com -P 3306 -u user -p lamdaApp < RDSdatabaseSchema.sql
    
    

    Give password.It will configure your database.

 

 

bCreate DynamoDB Table.

  • Go to this link https://console.aws.amazon.com/dynamodb/home and select Create Table option. You will get the following screen. Choose a name for your table and Choose a primary key type. You can choose whatever name you like. For this application we created table lambdaApp. This table name is required to connect with DynamobDB from Nodejs script. So note down this table name.  Here we are choosing hash for primary key and our hash attribute name is UserId. Then Click Continue.

 

8

 

  • On the next page we have not configured the indexes . Leave this page as is.
  • Next page you can configure the throughput capacity. This can be done according to the requirements.
  • In the final page you can enable basic alarm for your table. Provide your email id to get the notification. Press Continue.
  • Now you can review your table configuration and create  the table. After some time the table will be in the active state. Then you can use the database from our lambda function by requesting with the table name and hash primary key.
  • Click on the table name then it will open the table status. see the below image.

 

100

 

  • Then go to the Item tab and press Create Item button. then following window will pop up.

 

101

 

  • click on the plus( + ) button ,it will show three options, select the Append option then select String from the dropdown list.
  • After this you can add the items. In this application we use 3 items. The UserId is already created. so add Name and Status to this table then save it.

 

We will cover the methods to create and deploy lambda applicatioin package  in Part 3

AWS Lambda Tutorial: Step by step instructions to create a scalable web application – Part 1

Arunbalan
speedometer-653246_1920

Building scalable systems is often unmanageable even with cloud computing. Normally we  use Amazon AWS with  EC2 , load balancer and autoscaling. This approach is inconvenient and sudden traffic spikes cannot be handled with autoscaling. Additionally some infrastructure should be always kept in reserve.

Aws Lambda can be used to  solve these hassles of  AWS load balancing.  AWS Lambda is quite promising, easy to use  and does not have the above limitations. The trick of using AWS Lambda with Amazon API gateway can help you  build and scale web-applications with no infrastructure reservations.

AWS Lambda

AWS Lambda is a platform to make completely scalable applications with less effort and without the hassles of virtual machines. You need to upload your application code as “Lambda” functions to AWS. AWS Lambda runs your code on high-availability compute infrastructure and performs all the infrastructure functions, such as administration of the compute resources, capacity provisioning and automatic scaling. Those Lambda functions can be triggered by Amazon API endpoint, thereby exposing to the web. All you need to do is upload your code in one of the languages that AWS Lambda supports (currently Node.js or Java).

 

The Scenario

 

This document includes stepwise procedure for Building a completely scalable and reliable cloud based application using AWS Lambda.In this part we will see working example of scalabe lambda application.This involves creating a web Interface for app, construct AWS Lambda function, configure APIs in Amazon API Gateway and invoke the application from web browser.

This demo application is a poor man’s facebook. The source code is available at github  (https://github.com/Nethram/LambdaDemoApplication) It has 3 functionalities. Those are

  1. Creating user account with username and password.
  2. Update the user’s status.
  3. View every user’s status.

Use this link to test this application. It opens the following interface.

 

 

index_page

 

  • Provide a username and password to create your account.
  • Once an account is created, you may submit your username, password and your status in the second box.
  • You can then see the status of every user by submitting your username and password.

 

2nd

Source Code :https://github.com/Nethram/LambdaDemoApplication.

 

We will cover the nuts and bolts of connecting AWS resources with Lambda in Part2

Our Clients

SAMSUNG

ABS TRANSLATE

E RELEASES

LEFKOWITS LI

THE MOTELY FOOL

THE MEDICAL TEAM

TRULY WIRELESS

ATTENDENCE MANAGER

DIRECT MAILERS

E RELEASES

LEFKOWITS LI

ABS TRANSLATE

Our Services

Telecommunication

With our combined thirty years plus experience, we are experts in telecommunications and have made telecommunications easier to use for our clients.

READ MORE

Cloud Computing

Nethram team has a proven track record in accomplishing cloud computing services using Amazon AWS services, Google Cloud and Microsoft Azure.

READ MORE

Video On Demand

We are experts in video management, video hosting, video streaming, Roku channel development and Chromecast development.

READ MORE