Lambda
AWS Lambda is a serverless computing platform that allows users to create functions and run your code without provisioning or managing servers. It executes your code only when needed and scales automatically and we need to pay only for the compute time consumed.
Languages supported
- Java
- Nodejs
- Python
- Ruby
- Go
- Dotnet
Use Case
Today we are going to write a simple lambda function in nodejs which takes 2 strings as input and check if the first string is a substring of the second string.
{
"first' : "serverless",
"second" : "The art of serverless"
}
We will be receiving below response.
{
"substring" : true
}
Steps
a) Login to AWS management console
b Search for the service 'Lambda'
c) From the Lambda console click on create a function.
d) Fill in all the mandatory fields
d) Fill in all the mandatory fields
e) Add below code in index.js or the default handler specified.
exports.handler = async (event) => {
var first = event.first;
var second = event.second;
var substing = second.includes(first);
const result = {'substring' : substing };
// TODO implement
const response = {
statusCode: 200,
body: JSON.stringify(result),
};
return response;
};
f) To test the function create a test event like below
g) See the response below
I




Comments
Post a Comment