Lambda is a compute service where you can upload your code to and your code will be executed on your behalf using Amazon infrastructure.
Each piece of your code is called a function on the Lambda platform.Using Lambda is bit like porting your code to a server except that you don’t have to manage that and your don’t have to worry about scaling or availability.
Lambda functions can be written in Java, Python or Nodejs.
All the functions you upload to lambda are stateless.
All persistence data you can store using S3 and DynamoDB to store stateful information.
Lambda will automatically scale the incoming events and scale back down when needed. There is no autoscaling is configured. Everything is automatically handled by Amazon.
How can we trigger a Lambda function ?
Lambda functions can be trigger by events from other AWS services.
For example, you can trigger a lambda function when a new file is uploaded to S3 bucket. You can also trigger through HTTP.
Pricing :
Free Tier Available
1M requests
3M seconds of compute time each and every month.
No usage - no cost
First Lambda function in Nodejs
Go To AWS Console
Go to Compute Section and open Lambda
Choose runtime as NodeJS 4.3 , this is the latest stable version, please do not pick NodeJS older version - which is a legacy version.
We will go with simple hello-world function
Configure trigger section - we not going to set up triggers right now.
We just set up the function and in future, we are going to connect this function to api gateway.
Configure function section -
Name : Your function name example: random-number-generator
Description : Simple Lambda function
Runtime : NodeJS 4.3
you have options here
you can edit the code, you can upload the code.
‘use strict’
exports.handler = (event, context, callback) =>{
console.log(‘value1=’,event.key1);
callback(null,event.key1);
};